As a copy editor, my job involves optimizing the layout of scientific articles written by authors directly in LaTeX to ensure they conform to the styles of the journals I work for.
A common issue I encounter is the inappropriate use of the \left
and \right
macros, especially when equations are split across multiple lines. This often results in mismatched bracket sizes, which is visually unappealing and incorrect.
For instance, in the following equation (real case):
\begin{align}
P^{ij} & = -2 \sqrt{-g}\left\{G^{ijlm}\dot K_{lm} + \alpha K^{ij} K -\alpha g^{ij} K_{lm} K^{lm}+\alpha~\,R^{\hspace{-0.4cm}3\hspace{0.3cm}ij}\right. \nonumber \\
&\left.\qquad \qquad\quad -g^{ij}\left[\left(\frac{\alpha}3+2\beta\right)(~R^\3-3K_{lm}K^{lm}+K^2)+\gamma\right]\right\}, \label{Pijsol}
\end{align}
the corresponding brackets are of different sizes.
To speed up the correction of these cases, I thought I could define macros that allow me to replace \left
/\right
with, for example, \biggl
/\biggr
without needing to remove the corresponding \right.
/\left.
(to simplify and expedite my work).
For example:
\begin{align*}
x&=\left(y\right.\\
&\left.\qquad +\frac{1}{2}\right)
\end{align*}
should become something like:
\begin{align*}
x&=\lbiggl(y\right.\\
&\left.\qquad +\frac{1}{2}\rbiggl)
\end{align*}
and work like the following code:
\begin{align*}
x&=\biggl(\left.y\right.\\
&\left.\qquad +\frac{1}{2}\right.\biggr)
\end{align*}
The idea is to write a function in Emacs Lisp that automatically performs the replacements \left
--> \lbiggl
and \right
--> \rbiggr
for the first corresponding brackets after the cursor, simply ignoring the \right.
/\left.
.
Does my idea make sense? How can I define \lbiggl
/\rbiggr
and similar commands to achieve the desired effect?
I am also open to solutions that address the problem in other ways. (I am aware that alternative methods, such as \vphantom
, can be used, but the solution I am looking for should be focused on speed of implementation rather than formal rigor in the code.)
\left
and\right
are usually good for quick typesetting, but seldom for really good typesetting → tex.stackexchange.com/q/173717/277964. For good typesetting also visual control is needed and therefore simple automatism more and more often fail. However, if you want an automatism, see e.g. Torbjørn's answer to tex.stackexchange.com/q/21290/277964.\right
to a\left
or all\right
…\left
pairs with&
resp.\\
in between, maybe an emacs lisp forum could help you.\left.
and\right.
by nothing and then\left
and\right
by (say)\Bigl
and\Bigr
or by a custom lisp loop that asks the size in each case. adding spurious\left.\right.
will add unwanted horizontal space