Intertext causes overfull hbox in align* environment

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align*}
a & =b & & \text{if }
\begin{dcases*}
x = 2 \\
\shortintertext{and}
y = 3
\end{dcases*}\\
a & = c & & \text{ elswhere}
\end{align*}
\end{document}


produces, as expected,

but it causes an

Overfull \hbox (53.86888pt too wide) in paragraph

The shortintertext command seems to be the guilty one, is this use of it improper?

• Why \intertext{and} and not simply \text{and}\\? – egreg Aug 6 '15 at 14:14
• To use \shortintertext{and} without having to tweak manualy the inter-space... (so, the example is not relevant, I'll edit it). – Clément Aug 6 '15 at 14:17
• Both \intertext and \shortintertext should be used to interrupt a full display alignment, not a boxed one such as aligned, gathered, cases and similar ones. – egreg Aug 6 '15 at 14:20
• If I use \shortintertext{and}, I get exactly the same spacing as with \text{and}\\ (but with the overfull box warning). – egreg Aug 6 '15 at 14:23
• @egreg -- with \text{and}, i get very much wider spacing between the left-hand "column" and the right-hand one. that's avoided by using alignat* and inserting \quad as a left-hand-side spacer in one of the lines. but the whole construct is centered, not shifted left (caused by the full-line width of the \intertext element). – barbara beeton Aug 6 '15 at 14:29

The commands \intertext and \shortintertext should only be used to interrupt a full display environment (align, alignat, flalign) for keeping the alignment across two separated sets of formulas.

Both commands typeset a box as wide as the value of \linewidth outside the alignment. So it's not surprising you get an Overfull \hbox warning.

You just need \text; the spacing will be exactly the same as the one you get by abusing \shortintertext, but of course without the warning.

In the following, both inputs are compared.

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{align*}
a & =b & &
\text{if }
\begin{dcases*}
x = 2 \\
\text{and}\\
y = 3
\end{dcases*}\\
a & = c & & \text{elsewhere}
\end{align*}

\begin{align*}
a & =b & &
\text{if }
\begin{dcases*}
x = 2 \\
\shortintertext{and}
y = 3
\end{dcases*}\\
a & = c & & \text{elsewhere}
\end{align*}

\end{document}


Note that the \shortintertext version is pushed all the way left, because of the implied wide box.

If you want to reduce the gap between the two columns, use alignat*, for instance

\begin{alignat*}{2}

• arrggghhhh. you beat me to this. i still think that alignat* with a strategically placed \quad will look better. also, get rid of the input space at the beginning of { elsewhere}; that misalignment bugs me! – barbara beeton Aug 6 '15 at 14:35
• @barbarabeeton Done (I had already added the alignat* version). – egreg Aug 6 '15 at 14:37