3

This question led to a new package:
conteq

I am writing a paper with multiple chains of equations or inequalities, with optional explanations. Depending on the size of the equations, I use one of

\documentclass{article}
\usepackage{amsmath}
\begin{document}
Short style:
\begin{align*}
lhs1 &= rhs1 && \text{expl1} \\
     &\le rhs2 \\
     &= rhs3 && \text{expl3}
\end{align*}

Medium style:
\begin{align*}
lhs1 &= rhs1 \\
     &\phantom{{}={}} \text{expl1} \\
     &\le rhs2 \\
     &= rhs3 \\
     &\phantom{{}={}} \text{expl3}
\end{align*}

Large style:
\begin{align*}
     &\phantom{{}={}} lhs1\\
     &= rhs1 \\
     &\phantom{{}={}} \text{expl1} \\
     &\le rhs2 \\
     &= rhs3 \\
     &\phantom{{}={}} \text{expl3}
\end{align*}
\end{document}

This looks nice, but is not convenient to switch between. So I’d like to have three environments eqchains, eqchainm and eqchainl that produce the appropriate output, given an input in this form:

\begin{eqchain?}
lhs1 &= rhs1 & expl1 \\
     \le rhs2 \\
     = rhs3 & expl3 
\end{eqchain?}

(Of course, the & can be some other symbol). Bonus points if the styling of the explanation can be modified by redefining a macro, e.g. \newcommand{\eqchainexpl}[1]{\text{\{ \textit{#1} \}}.

And, if that was possible, I’d like to have an environment eqchain that automatically selects the right environment using the following heuristics: If lhs1 and the largest rhs is together smaller than ⅔ of the \linewith, use eqchains. If the lhs1 and the largest rhs is smaller than the \linewidth, use eqchainm. Otherwise use eqchainl. Final bonus points if the explanation is set in a \parbox so that long explanations are wrapped and do not affect the horizontal positioning of the math content.

ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149

1 Answers1

2

As it seems that no existing package was able to provide this feature, I did it myself and created the conteq package. It does not (yet) do automatic layout selection, but provides a few layout and new ones can easily be added.