11

This is basically the setup:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
a &= b + c\\
a &= b + c\\
\center{a = b + c \quad a = b + c}
\end{align}
\end{document}

I would like to have the last line in the align environment centered independently of the lines above.

15

A single equation in align is centered, so with gather you get both equations centered; otherwise, nest align inside gather.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

A single equation in \texttt{align} is centered, so with \texttt{gather}
you get both equations centered:
\begin{gather}
a = b + c
a = b + c \quad a = b + c
\end{gather}
If you have \emph{two} equations to align with each other and
one to be centered, nest \texttt{align} in \texttt{gather}
\begin{gather}
\begin{align}
a &= b + c\\
x &= b + c + d + e
\end{align}\\
a = b + c \quad a = b + c \quad a = b + c
\end{gather}

\end{document}

enter image description here

  • I was experimenting a similar solution, but with aligned inside gather, with two alignment groups. Strangely it didn't result in the normal spacing between the groups, while alignedat{2} works fine, or your align solution. Can you explain it? – Bernard Aug 22 '16 at 18:04
  • @Bernard The problem with aligned is that it doesn't number each row. – egreg Aug 22 '16 at 18:13
  • But it might be wanted so in some situations: just one number for the rows in aligned, coming from gather. – Bernard Aug 22 '16 at 18:16
  • Thanks, nesting align in gather solved it! How could I have figured this out myself? – Lenar Hoyt Aug 22 '16 at 21:24
  • 2
    @LenarHoyt Page 29 in the manual of amsmath: “The structures align, alignat, etc., are designed for top-level use and for the most part cannot be nested inside some other displayed equation structure. The chief exception is that align and most of its variants can be used inside the gather environment.” I acknowledge it's not really so prominent. ;-) – egreg Aug 22 '16 at 21:28
4

I suspect you actually want to use a gather environment.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather}
a = b + c\\
d = e + f \qquad g = h + i
\end{gather}
\end{document}
  • But there are more equations above which are aligned (fixed this in my question). – Lenar Hoyt Aug 22 '16 at 17:53
  • @LenarHoyt - I'm afraid it's quite unclear to me what your actual formatting objectives may be. By the way, are you really trying to typeset trivial equations of the form a = b + c? If not, please post the actual equations you're looking to typeset. Please also be more specific as to what you're trying to achieve. – Mico Aug 22 '16 at 17:56
  • @LenarHoyt - Is there something stopping you from taking my code and inserting an additional row in the gather environment? – Mico Aug 22 '16 at 18:15
2

Is it this what you want to achieve?

\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
\lipsum[2]
\begin{align}
a &= b + c\\
a &= b + c & a &= b + c
\end{align}
\lipsum[2]
\end{document}

enter image description here

  • Sorry, I had a typo in my question. I've updated it. – Lenar Hoyt Aug 22 '16 at 17:00
2

Your MWE is not clear about the variables you want to align with each other. Please, make the variables unique and say which ones you want to align with each other, so you can get a helpful answer.

For centering, I think align always centers the equations, but if you wish to control the spacing, you may consider alignat.

If you you don't care about aligning the second equation, then you need to go with gather not align

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{alignat}{2}
    a &= b + c \quad &\\
    x &= y + z & a &= b + c
\end{alignat}

\begin{gather} 
    a = b + c\\
    a = b + c \quad a = b + c
\end{gather}
\end{document}

enter image description here

  • Sorry, I had a typo in my question. I've updated it. – Lenar Hoyt Aug 22 '16 at 17:00
  • @LenarHoyt does this help? – Diaa Aug 22 '16 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.