Math & Sciencecenter an alignat tab alignment character

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
CoolnessItself
Posts: 47
Joined: Wed Nov 11, 2009 9:30 pm

center an alignat tab alignment character

Post by CoolnessItself »

I have several lines I'd like to line up with their = signs. It might look like this

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{alignat*}{2}
x_1 &= 5\\
x_2 &= 7\\
x_3 &= 10\\
\end{alignat*}

\end{document}
As that is formatted now, it's pretty much in the center. I'd like to keep it there, but add a long comment

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{alignat*}{2}
x_1 &= 5\\
x_2 &= 7 &\qquad \mbox{a loooooooooooooooong comment}\\
x_3 &= 10\\
\end{alignat*}

\end{document}
Is there a way to retain the original position and force the = to be centered? The comment should appear to the right, not like an equation number, but more like a \forall j \in ...
It's the only one with a comment so it seems silly that it takes away the focus from the equations themselves

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

center an alignat tab alignment character

Post by frabjous »

Something very similar to this was discussed in this old thread.

The suggestion I gave there (though there are others to try too) would do something like this:

Code: Select all

\begin{align*}
x_1 &= 5\\
x_2 &= 7 \put(0,0){\qquad loooooooooooooooong comment}\\
x_3 &= 10\\
\end{align*}
Post Reply