1

In a guide I was proposed with the following problem, long equations inside an align environment are more involved to handle when the goal is to properly align the equality signs of multiple equations but also wrapped lines - like this:

enter image description here

Using the align environment, one simple way proposed was to add the right amount of space (equal to a length of = and a space), the book proposed to use \mathrel{\phantom{=}} \negmedspace{}

\begin{align}
    a &= b + c \\
      &= d + e + f + g + h + i \\ 
      &\mathrel{\phantom{=}} \negmedspace{} + j + k + l + m + n + o \\
      &= p + q + r + s    
\end{align}

My first question is, what is the purpose of both the \mathrel and the \negmedspace specifically here?

I also found that \phantom{=\ } has just the same effect and looks more straightforward/easier to recall or come up with. Are there potential problems with that? And generally asking, is there another good way to achieve the desired effect?

  • 1
    I see no purpose in that markup at all and would replace \mathrel{\phantom{=}} \negmedspace{} by \qquad – David Carlisle Sep 28 '20 at 23:36
  • Just a comment since I don't have time to test it. Since it's more logical that a broken line have just one number, I'd try using aligned to line up those two parts on the first plus sign: ... = d \begin{aligned} &+ e + f ... \\ &+ j + k ... \end{aligned}\\ &= p ... \end{align} – barbara beeton Sep 29 '20 at 03:53

1 Answers1

0

The purpose of \mathrel is to ensure that \phantom{=} is interpreted the same way = - a math relational symbol - on its own would be interpreted. Here's a view of how \mathrel affects the spacing:

enter image description here

\begin{align}
  a &= \text{some RHS} \\ 
    &\mathrel{\phantom{=}} \text{some RHS with mathrel} \\
    &\phantom{=} \text{some RHS without mathrel} \\
    &{=} \text{some RHS without mathrel}
\end{align}

With \mathrel, the word some is aligned vertically with one another. Without it, they don't align. That's because \phantom removes the "relational attribute" of the = operator.

Now consider \negmedspace. This is equivalent to a negative medium space which is inserted around binary relations like + (see How to change default for spacing around binary relations?). So this technically pushes the + to the left so it's flush with the other element above it (d in this case):

enter image description here

\begin{align}
  a &= b + c \\
    &= d + e + f + g + h + i \\ 
    &= \negmedspace{} + j + k + l + m + n + o \\
    &\mathrel{\phantom{=}} \negmedspace{} + j + k + l + m + n + o \\
    &= p + q + r + s    
\end{align}

The alignment "requirement" is usually different for different people and therefore subjective. Some people like to emphasize a continuation from the line above and insert a wider space, while others enjoy a more rigid horizontal alignment. Here's a view with the former in place:

enter image description here

\begin{align}
  a &= b + c \\
    &= d + e + f + g + h + i \\ 
    &\phantom{{}={}} \quad + j + k + l + m + n + o \\
    &= p + q + r + s    
\end{align}

Note that \phantom{{}={}} achieves the same spacing as \mathrel{\phantom{=}}, ensuring that = (or \phantom{=}) is interpreted as a math relation.

Werner
  • 603,163