TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question led to a new package:

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

Short style:
lhs1 &= rhs1 && \text{expl1} \\
     &\le rhs2 \\
     &= rhs3 && \text{expl3}

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

Large style:
     &\phantom{{}={}} lhs1\\
     &= rhs1 \\
     &\phantom{{}={}} \text{expl1} \\
     &\le rhs2 \\
     &= rhs3 \\
     &\phantom{{}={}} \text{expl3}

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:

lhs1 &= rhs1 & expl1 \\
     \le rhs2 \\
     = rhs3 & expl3 

(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
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
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


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.