开发者

Unix: replace every odd | with \left| and every even | with \right|

开发者 https://www.devze.com 2022-12-27 22:19 出处:网络
An enormous equation. You need to add \\left| on the left side of corresponding |. The corresponding | you need to replace with \\right|.

An enormous equation. You need to add \left| on the left side of corresponding |. The corresponding | you need to replace with \right|.

Equation

\begin{equation}
| \Delta w_{0} | = \frac{|w_{0}|}{2} \left( |\frac{\Delta g}{g}|+|\frac{\Delta (\Delta r)}{\Delta r}| + |\frac{\Delta r}{r}| +|\frac{\Delta L}{L}| \right)
\end{equation}

[Premises]

  1. The amount of | is even.
  2. No nesti开发者_如何学JAVAng. So scenario such as M_OPEN|----X_OPEN|-----X_CLOSED|------M_CLOSED| is not possible, just M_OPEN|---M_CLOSED|---H_OPEN|----H_CLOSED|.


 sed -r -e 's/\|([^|]+)\|/\\left|\1\\right|/g'

But this works only if you do not have nested |...|.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号