2

How to put text at the end of a line (outmost right) in an align* environment? I have a set of equations in align* and at the end of each line I want to write a little bit text which explains that line. And I want it to be at the right of each line.

4
  • Can you provide a foundational document we can work with that replicates your current setup? Something we can copy-and-paste-and-compile and see exactly your what you're seeing. It should start with \documentclass and end with \end{document}. It'll make it easier to get you the solution(s) you want. Can you do that?
    – Werner
    Apr 13 at 22:12
  • @user202729 -- The question asks for textual notations flush right. The question you link will place annotations to the right, but not reliably flush right. Apr 14 at 1:51
  • @barbarabeeton To be fair the answer that (ab)use \tag does satisfy that. tex.stackexchange.com/a/27285/250119 Plus && is what people normally want anyway, and "right of each line" may not necessarily mean flush right. (maybe need OP to clarify)
    – user202729
    Apr 14 at 2:39
  • @user202729 -- I interpret "outmost right' to mean "flush right", but yes, it would be a good thing for the OP to clarify. Regarding the use of \tag, it's buried in a comment that if the option leqno is chosen, the "tag" will end up on the left. So this is not foolproof. I've seen requests for flush right annotations rather often, and although most authors give in and settle for "shoved right and aligned", the request is a legitimate one and deserves a definitive answer. Apr 14 at 2:56

1 Answer 1

0

There are two different kinds of objects that can adorn an equation:

  1. a number or tag or
  2. an “explanation”.

The number or tag doesn't belong in the equation: it's just a convenience for cross references, handier than “the third equation on page 234”.

An explanation instead is part of the equation (or the step in a derivation) and should not be flush right. The code:

\begin{alignat*}{2}
a+(b+s(c))
&=a+s(b+c)    &\qquad& \text{(definition)} \\
&=s(a+(b+c))  && \text{(definition)} \\
&=s((a+b)+c)) && \text{(induction)} \\
&=(a+b)+s(c)  && \text{(definition)}
\end{alignat*}

enter image description here

The same (ab)using \tag:

\begin{align*}
a+(b+s(c))
&=a+s(b+c)    \tag{definition} \\
&=s(a+(b+c))  \tag{definition} \\
&=s((a+b)+c)) \tag{induction} \\
&=(a+b)+s(c)  \tag{definition}
\end{align*}

enter image description here

But this has an obvious problem: if the document class specifies leqno, you'd get

enter image description here

with no warning.

A possible way out is to use flalign*

\documentclass[leqno]{article}
\usepackage{amsmath}
\usepackage{showframe}

\begin{document}

After observing that $a+(b+0)=a+b=(a+b)+0$ we can proceed to prove
the associativity of addition by induction, namely
\begin{flalign*}
&&a+(b+s(c))
&=a+s(b+c)    &&\text{(definition)} \\
&&&=s(a+(b+c))  &&\text{(definition)} \\
&&&=s((a+b)+c)) &&\text{(induction)} \\
&&&=(a+b)+s(c)  &&\text{(definition)}
\end{flalign*}


\end{document}

enter image description here

But I'd stay with the first display, for the reasons outlined at the beginning.

Not the answer you're looking for? Browse other questions tagged .