1

Ahoy,

so basically, I have a three-line set of equations. I want the first two lines to be aligned at the first = sign, and the last line's right end to be at the second-to last line's right end.

I tried to make sense of the alignat environment for this purpose, but I found it very difficult to actually understand what the commands do. My minimum (not-)working example is as follows:

\documentclass[10pt]{article}
\usepackage{amsmath}

\begin{document}
    \begin{alignat}{2}
        a &= b + c &\\
        G (y_k^n) &= G((y_k^n)_0 + \delta y_k^n) = (G)_0 + \delta G = 0, & \\
        & k=0,\ldots 3; n=0,\ldots, N-1 & \nonumber 
    \end{alignat}
\end{document}

which currently produces: 3-line equation produced from the code above. All three lines are aligned at the first alignment tab, and the alignment tabs on the right do not seem to do anything.

How do I persuade it to put the last line at the right edge of the second line?

1
  • 1
    Welcome to TeX.SE.
    – Mico
    Commented Jul 15, 2021 at 15:55

1 Answer 1

1

Here's a solution that doesn't use an alignat environment. It works by nesting an aligned environment inside an align environment.

Observe that there are no & alignment markers inside the two-line aligned environment; this forces both lines to be aligned flush-right (aka ragged-left).

enter image description here

\documentclass{article}
\usepackage{amsmath} % for 'align' and 'aligned' environments
\begin{document}
    \begin{align}
                a &= b + c \\
        G (y_k^n) &= 
          \begin{aligned}[t]
            G((y_k^n)_0 + \delta y_k^n) = (G)_0 + \delta G = 0 , \\
            k=0,\dots 3;\ n=0,\dots, N-1 .
          \end{aligned}
    \end{align}
\end{document}
2
  • 1
    Thank you very much, this looks exactly like what I need.
    – DonLouigi
    Commented Jul 17, 2021 at 9:17
  • @DonLouigi - You're most welcome!
    – Mico
    Commented Jul 17, 2021 at 9:34

You must log in to answer this question.

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