Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Latex AMS align / Align multiple "=", too much space

Tags:

latex

I'd like to align some equations in Latex using the AMS packages. Each equation has two equal signs that need to be aligned. So something in the line of

A = B = C D = E = F 

I've tried using the align-environment like this

\begin{align} A &= B &= C \\ D &= E &= F \end{align} 

This works in principle (it aligns), however it adds ridiculously large spaces before the second equal sign in each line. But I just want the line to runs as if there was no additional alignment tab. Only when I replace for example "B" by "BBB" I want the equal sign before "F" to shift to right the exact amount of space.

Could anyone help me out on that one? It's kind of driving me crazy since I don't get the idea of that strange behavior and I just can't find any solution. Maybe alignat could help, but I don't really get how that environment works or in how it differs from normal align.

Cheers, Oliver

like image 242
janitor048 Avatar asked Dec 05 '10 21:12

janitor048


People also ask

How do I align multiple equal signs in LaTeX?

The eqnarray environment lets you align equations so that, for example, all of the equals signs "=" line up. To do this, put ampersand "&" signs around the text you want LaTeX to align, e.g. Each equation can be labelled separately, just put the label command after the relevant equation.

How do you break align equations in LaTeX?

Insert a double backslash to set a point for the equation to be broken. The first part will be aligned to the left and the second part will be displayed in the next line and aligned to the right.

How Align Align Right in LaTeX?

Right. The environment \begin{flushright}... \end{flushright} does the opposite of flushleft , and the text will be aligned with the right-hand margin, and have a ragged left-hand edge.


2 Answers

This should work:

\begin{alignat}{2}   A &= B & &=  C \\   D &= E & &=  F \end{alignat} 

From ams guide:

A variant environment alignat allows the horizontal space between equations to be explicitly specified. This environment takes one argument, the number of “equation columns”: count the maximum number of &s in any row, add 1 and divide by 2.

Its not exactly intended for what you are trying to do, but since align insists on adding space... The idea behind align is:

l&=r   &   l&=r \\ l&=r   &   l&=r 

One '&' per function, and a '&' between functions.

I would hope there is a better solution though.

like image 135
qonf Avatar answered Sep 24 '22 14:09

qonf


(6½ to 8 years later)

What about using array with a custom separator?

\begin{array}{r@{\ }c@{\ }l} A &= B &= C \\ D &= E &= F \end{array} 
like image 24
Solomon Ucko Avatar answered Sep 26 '22 14:09

Solomon Ucko