Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
2  
Please always make your examples into complete runnable documents (which allows them to be tested (by you and others). Here I think you are missing a \\ after lhs1 in the "large` example (or you want a layout I find rather strange) –  David Carlisle Apr 12 '13 at 8:36
    
Added missing `\` and a document preamble. –  Joachim Breitner Apr 12 '13 at 8:40
    
Instead of \phantom{{}={}} use \mathrel{\phantom{=}} –  Marco Daniel Apr 12 '13 at 9:23

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.