2

I'm trying to get something really simple to work but LaTeX is being annoying.

y &= f(x)  \\
z &= y \times && p \\
& \times && q 

I want the && to be aligned but right now it produces the following:

[annoying latex]1

1
  • 2
    It would be nice to post a full compilable code. Could help to understand what happens…
    – Bernard
    Dec 18, 2017 at 19:54

1 Answer 1

2

There are a number of ways you can obtain the alignment you seek:

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{alignat*}{2}
  y &= \mathrlap{f(x)} \\
  z &= y & {}\times{} & p \\
    &    & {}\times{} & q
\end{alignat*}

\begin{align*}
  y &= f(x) \\
  z &= y \times p \\
    &\phantom{{}= y} \times q
\end{align*}

\end{document}

The first uses an alignat structure, but requires you to ensure that the first equation doesn't interfere with the alignment of the second/third. The second option inserts the appropriate \phantom to have the \times aligned.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .