Center one equation of many in align?

I have the following align enviroment:

\documentclass[12pt]{memoir}
\usepackage{amsmath}
\begin{document}
Here we see
\begin{align}
\text{cat} &= \text{dog}\\
\text{dog} &= cute
\intertext{and if we remove}
\text{dog}\\
\intertext{we get}
\text{cat} &= cute
\end{align}
\end{document}


Which creates:

How do I center equation 3 while keeping everything else aligned? I can get close by putting in an & in the real equation, but it's still not perfectly centered.

With the gathered environment. Better using mathtools instead of amsmath (it's an extension that loads amsmath and fixes two bugs in it). Here is how:

\documentclass[12pt]{article}
\usepackage{mathtools}
\usepackage[showframe]{geometry}

\begin{document}

\begin{align}
\text{catxxxxxxxxxxxxxxxxxxxx} &= \text{dog}\\
\text{dog} &= \text{cute}\\
\intertext{and if we remove}
\begin{gathered}
\text{and if we remove dog}
\end{gathered} \\
\intertext{we get}
\text{cat} &= \text{cute}
\end{align}

\end{document}


• This looks like it works more properly. I'll try mathtools. Mar 11, 2014 at 21:54
• It's an extension to amsmath: it loads it, and by default fixes two bugs in amsmath. Mar 11, 2014 at 21:58
• Yep, it worked though I had to figure out \mathclap (I think). Otherwise it wasn't centering. Mar 11, 2014 at 22:00
• @bombcar note that that this doesn't actually answer the question (although it makes a reasonable layout on the MWE) It puts the centre of the dog line at the alignment point which only approximately centres the line as cat=cute have similar length, if you change the first line to \text{catxxxxxxxxxxxxxxxxxxx} &= \text{dog}\\  you'll see the dog line moves using this approach but stays if it is set in equation Mar 11, 2014 at 23:02
• @David Carlisle: You're perfectly right. Actually I added \clap \ or \mathclap when I observed the "gathered" part wasn't really centred. It must have been because of some other code in my file, which I've deleted since then. So simply using the gathered environment gives the same result as equation, but it seems to me more natural to use gathered, and you can have several gathered lines. Mar 11, 2014 at 23:36

\documentclass[12pt]{memoir}
\usepackage{amsmath}
\begin{document}
Here we see
\begin{align}
\text{cat} &= \text{$$dog$$}\\
\text{$$dog$$} &= cute
\intertext{and if we remove
$$dog$$
we get\vspace{-\baselineskip}}\\
\text{cat} &= cute
\end{align}

\end{document}

• Oh! You can put equation inside intertext. It works but seems naughty somehow! Mar 11, 2014 at 21:47
• @bombcar well i can't say I've ever done it before but it was worth a try. It doesn't really work it makes the first following line of the align to be not numbered, which is why I add the \\  and back up a row so the cat line gets numbered. If you look at the chat site you'll see a comment about that:-) Mar 11, 2014 at 21:51
• It's close enough for what I needed, so it's good enough for me. I'm kind of surprised that amsmath doesn't already have some default for it, though. Mar 11, 2014 at 21:53
• @bombcar: I modified my answer to take David Carlisle's remark into account. It makes me coming back to my initial answer, which was very close to his's. Gathered offers the possibility to have several lines centred within one environment, which equation can't do. Mar 11, 2014 at 23:43
• @Bernard no this answer centres the dog line on the text block, so it is unlike yours (but it is probably an abuse of the ams code:-) Mar 11, 2014 at 23:44

In this case, it seems to be safe to use \multispan:

\documentclass[12pt]{memoir}
\usepackage{amsmath}

\newcommand{\equationinalign}[1]{%
\multispan{2}%
\hfill$\displaystyle{#1}$\hfill
\ignorespaces
}

\begin{document}
\noindent
\hspace*{\fill}\smash{\vrule depth 10cm width 0.1pt}\hspace*{\fill}

Here we see
\begin{align}
\text{cat} &= \text{dog}\\
\text{dog} &= \text{cute}\\
\intertext{and if we remove}
\equationinalign{\text{dog}}
\intertext{we get}
\text{cat} &= \text{cute}
\end{align}

\end{document}