Math & ScienceEquation alignment with long tags

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
feynman44
Posts: 6
Joined: Sat Aug 06, 2011 10:10 am

Equation alignment with long tags

Post by feynman44 »

When using the {equation} or align environments, I occasionally like to insert right-aligned parenthetical explanations on each line (see MWE below). I have been achieving this using the \tag command, but this offsets the equation so that it is no longer centered on the page.

Is there a way to create a tag without affecting the alignment of the equation? Or perhaps there is a better way to do this without using the \tag command? Thanks in advance for your help!

Code: Select all

\documentclass[10pt,letterpaper]{article}
\usepackage{amsmath, geometry}
\geometry{top=1in, bottom=1in, left=.92in, right=1.28in}

\begin{document}
Equation without tags:
\begin{align*}
a^{-1}ba&=b\\
a(a^{-1}ba)&=ab\\
(aa^{-1})ba&=ab\\
eba&=ab\\
ba&=ab
\end{align*}

Equation with tags:
\begin{align*}
a^{-1}ba&=b\\
a(a^{-1}ba)&=ab\tag{multiply by $a$ on the left}\\
(aa^{-1})ba&=ab\tag{associativity}\\
eba&=ab\tag{inverse}\\
ba&=ab\tag{identity}
\end{align*}
\end{document}
Last edited by feynman44 on Thu Mar 22, 2012 5:26 am, edited 1 time in total.

Recommended reading 2024:

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

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

kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Re: Equation Alignment with custom Tags

Post by kaiserkarl13 »

The align and align* environments, try to set "tab stops" when aligning equations that minimize the imbalance of whitespace around the tags. Your tag "(multiply by a on the left)" is long enough that the TeX penalties add up to a lower value when it centers the equation between the tag and the left margin than it does when it centers it between margins (which is what you wanted).

I got it to do what I think you want it to do by deleting the word "the", which makes the distance between equation and tag large enough that TeX still finds it preferable to center between margins.

I don't know enough about how TeX centers equations to figure out which penalty needs to be tweaked to make it ALWAYS do it that way, but it might exist.
feynman44
Posts: 6
Joined: Sat Aug 06, 2011 10:10 am

Re: Equation Alignment with custom Tags

Post by feynman44 »

Thanks for the input, kaiser. That's right, I did notice that the alignment is only affected when the tag is a certain length. Changing the penalty, if possible, would be the perfect solution.
Post Reply