[Tex/LaTex] Align environment: take exact control of tab position

alignhorizontal alignmentmath-mode

I was wondering if it is possible to take control of the exact position of the tab in an align environment.

Like so:

\begin{align}[2cm]
A &= x^3 + 14789\\
B &= f^6
\end{align}

Which should then place both '=' signs at exactly 2cm from the left margin. No matter how long the expressions before and after '=' are.

Does anyone know how to do something like that?

Best Answer

In the following minimal example, the LHS ends at exactly 2cm from the left margin. The use of the flalign environment (from amsmath) with an additional alignment operator & pushes everything flush to the left margin, while a box of width 2cm leaves the LHS at the correct position.

enter image description here

\documentclass{article}
\usepackage{showframe}% http://ctan.org/pkg/showframe
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\begin{flalign}
\makebox[2cm][r]{$\displaystyle A$} &= x^3 + 14789 & \\
B &= f^6
\end{flalign}
\noindent\rule{2cm}{1pt}
\end{document}

Only A is set in a 2cm block, since B is "short enough". Otherwise, you can set whatever in a 2cm box, regardless of the size.

showframe was used to identify the text block border.

Related Question