2

I'm unable to get the formatting correct when attempting to add a comment to an equation that uses leqno. Ideally, I'd like the equation to remain centered regardless of whether or not it is numbered. Any suggestions would be greatly appreciated.

\documentclass[12pt, leqno]{book}
\usepackage{amsmath}
\begin{document}
\noindent The equation is centered and does not contain a comment. Everything looks fine here.
\begin{equation}
   (a+b)^2=a^2+2ab+b^2 
\end{equation}
 Adding a comment using align no longer centers the equation and the comment is not right justified.
\begin{align}
   (a+b)^2&=a^2+2ab+b^2 && \text{Right justify me!}
\end{align}
Commenting on an unnumbered equation causes equation to become uncentered and comment is on the wrong side.
\begin{equation*}
  (a+b)^2=a^2+2ab+b^2 \tag*{(Wrong side) }
\end{equation*}
\end{document}

enter image description here

3 Answers 3

2

You can do what you want with flalign and \llap:

\documentclass[12pt, leqno]{book}
\usepackage{amsmath}

\begin{document}

\noindent The equation is centred and does not contain a comment. Everything looks fine here.
\begin{equation}
  (a+b)^2=a^2+2ab+b^2
\end{equation}


With \verb+flalign+ and \verb+\llap+, it remains centred:
\begin{flalign}
  & & (a+b)^2&=a^2+2ab+b^2 && \llap{Right justify me!}
\end{flalign}

\end{document}

enter image description here

1

Possibly not very satisfying for you, but flalign does the job:

\documentclass[12pt, leqno]{book}
\usepackage{amsmath}
\begin{document}
\noindent The equation is centered and does not contain a comment. Everything looks fine here.
\begin{equation}
   (a+b)^2=a^2+2ab+b^2
\end{equation}
Adding a comment using align no longer centers the equation and the comment is not right justified.
\begin{flalign}
  &&(a+b)^2=a^2+2ab+b^2
  &&\text{Right justify me!}
\end{flalign}
\end{document}

You may want to insert by hand some space between the first two &. On the other hand, I don't think that flushing the comment to the right really helps the understanding of the equation.

enter image description here

0

As described in this question, you could switch between leqno und reqno and then use the \tag*{•} macro.

\documentclass[12pt]{book}
\usepackage[leqno]{amsmath}

\makeatletter
\newcommand{\leqnomode}{\tagsleft@true}
\newcommand{\reqnomode}{\tagsleft@false}
\makeatother

\begin{document}
\begin{equation}
   (a+b)^2=a^2+2ab+b^2 
\end{equation}

\reqnomode
\begin{align*}
  (a+b)^2=a^2+2ab+b^2 \tag*{Right side}
\end{align*}
\leqnomode

\begin{equation}
   (a+b)^2=a^2+2ab+b^2 
\end{equation}

\end{document}

Output:

output

You must log in to answer this question.

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