53

What is the way to achieve something between gather and aligned?

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[utf8]{inputenc}

\begin{document} \begin{gather} 3(a-x) = 3.5x + a - 1 \ 3a - 3x = 3.5x + a -1 \ a = \frac{13}{4}x - \frac{1}{2} \end{gather}

\begin{equation} \begin{aligned} 3(a-x) = 3.5x + a - 1 \ 3a - 3x = 3.5x + a -1 \ a = \frac{13}{4}x - \frac{1}{2} \end{aligned} \end{equation} \end{document}

Result:

enter image description here

But... How to achieve something like this? I'd like to keep the centering. enter image description here

Is this possible somehow?

1 Answers1

59

The gathered environment, used within math mode, is what you're looking for.

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{equation}
\begin{gathered}
3(a-x) = 3.5x + a - 1 \\
3a - 3x = 3.5x + a - 1 \\
a = \frac{13}{4}x - \frac{1}{2}
\end{gathered}
\end{equation}
\end{document}

output

Wikibooks LaTeX has a fairly nice list of the different kinds of equation and align environments.

cfr
  • 198,882
Arun Debray
  • 7,126
  • 2
  • 30
  • 54
  • 3
    This works great, but the numbering is put at the bottom if the equation is too big. Is there a way to force the number to be on the center (right)? – Guilherme Salomé Jun 21 '18 at 15:07
  • @GuilhermeSalomé place \kern-50pt before \begin{gathered} Here I used an arbitrary/context dependent negative left shift of length 50pt. Specifically, you can use any length to suit your need. Warning: most would advise against this because the math will overlap the left margin. – Alberto Takase Feb 23 '21 at 23:14
  • You probably want to use aligned instead of gathered. Just swap the terms and add &s to the =s. – Suuuehgi Aug 08 '22 at 16:01