3

Consider the following MWE

\documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} &abcde \\ &= vwxyz \end{align*} \end{document} 

This produces

enter image description here

I would like to align the start of the top line (the 'a') with the start of the expression on the bottom line (the 'v').

I tried moving the alignment character after the '=', but it messes up the spacing around the equals sign:

\documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} &abcde \\ =& vwxyz \end{align*} \end{document} 

enter image description here

I also tried using a phantom '=', but it only seems to account for the width of the equals sign itself, not the spacing around it:

\documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} &\phantom{=} abcde \\ &= vwxyz \end{align*} \end{document} 

enter image description here

What is the correct way to achieve this?

4
  • Almost the same as spacing - How to align displayed, multi-line computations - TeX - LaTeX Stack Exchange Commented Jul 27, 2022 at 5:45
  • On examining the linked question, it is asking for something slightly more complicated and has more complicated answers as a result - I don't think it's the same. Commented Sep 7, 2023 at 10:07
  • At the moment I don't see, whether or not the 5 or 6 answers, David proposes in tex.stackexchange.com/questions/10408/…, did or did not help. Commented Sep 7, 2023 at 10:15
  • @MS-SPO I think if you compare them to Mico's answer below you will see that they are all more complicated. This is because they are answers to a different question. If a future user has the same question as me, they are more likely to be helped by the answers below, which are answers to my question, than by answers to the linked question, which are answers to a different question. Commented Sep 7, 2023 at 10:22

2 Answers 2

6

Unfortunately, the typical answer at SE is "how to do it" but not "why". I try to fill the gap.

The LaTeX align environment works (rougly speaking) like

\halign{\hfil$\displaystyle{#}$&$\displaystyle{{}#}$\hfil\cr ...data&data... \cr} 

It means that the first column is set by $\displaystyle{data}$ but the second one by $\displaystyle{{}data}$. The emtpy group {} here creates an empty math atom of Ord type. The idea is copied from Plain TeX macros.

If data in the second column is =abc then the result is {{}=abc}. The equal sign creates an atom of Rel type. We see here Ord Rel Ord Ord Ord. The Ord-Rel pair gives \thickmuskip space between them and Rel-Ord gives the same space, so we have spacing around the equal sign.

If the data in the fist column is = then we have {=} and it creates the Ord atom with equal sign in the nucleus without spacing. But if the data is ={} then we have {={}}, i.e. Rel-Ord which makes \thickmuskip space between Rel and Ord.

The spacing between math atoms are controlled using the table given at page 170 in TeXbook. You can see similar table in this document at page 3.

1
  • Future readers might want to note: this great answer gives the 'why'; the 'how' is in Mico's answer below. (Basically just replace =& with ={}& in my first code example.) Commented Sep 7, 2023 at 10:04
3

I would like to align the start of the top line (the a) with the start of the expression on the bottom line (the v). ... I tried moving the alignment character after the =, but it messes up the spacing around the equals sign.

Just change

 &abcde \\ =& vwxyz 

to either

 &abcde \\ ={}& vwxyz 

or

 &abcde \\ {}={}& vwxyz 

A full MWE:

enter image description here

\documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} &abcde \\ {}={}& vwxyz \end{align*} \end{document} 
2
  • @Zarko - Yes, it is. I'll adjust the answer accordingly. Commented Jul 27, 2022 at 4:02
  • The {}={} version adds undesired space; ={} is the one. Commented Jul 27, 2022 at 9:28

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.