7

If I replace an align* environment with the empheq environment (of align* flavor) the spacing behavior changes: With empheq the spacing depends on the amount of text in the last line of the previous paragraph, with align it does not (see mwe).

How can I make empheq behave just like align without messing around with the spacing manually? The reduced spacing may be a good thing for small equations (as in the mwe), but if I use empheq my equations are always large enough that I feel the extra space is a good thing..

\documentclass{article}
\usepackage{blindtext}
\usepackage{empheq}
\begin{document}

\blindtext
\begin{empheq}{align*}
f(x) = x^2 % less spacing than align
\end{empheq}

\blindtext Test test test test test test test.
\begin{empheq}{align*}
f(x) = x^2 % more text on last line of paragraph => same spacing as align
\end{empheq}

\blindtext
\begin{align*}
f(x) = x^2
\end{align*}

\blindtext
\end{document}

Edit. Just to be clear: It's not so much that I dislike the fact that the environment is sensitive to its surrounding, with a little more space I would even prefer this. But I use \[ .. \] or align* for my other equations and the inconsistent spacing is really noticeable and makes my other equations stand out.

1
  • I use empheq to add braces around multiline equations, by the way. Commented Jun 21, 2014 at 15:39

1 Answer 1

2

You can patch \empheq to set the “short skips” equal to the non short ones:

\documentclass{article}
\usepackage{blindtext}
\usepackage{empheq}
\usepackage{xpatch}

\ExplSyntaxOn
\xpretocmd{\empheq}
  {\abovedisplayshortskip=\abovedisplayskip
   \belowdisplayshortskip=\belowdisplayskip}
  {}{}
\ExplSyntaxOff

\begin{document}

\blindtext
\begin{empheq}{align*}
f(x) = x^2 % less spacing than align
\end{empheq}

\blindtext
\begin{align*}
f(x) = x^2
\end{align*}

\blindtext
\end{document}

enter image description here

1
  • Hmmm... Even if one can do it, doesn't mean one should. @egreg, I know you know all of this so this is for others: It is well-known that the spacing in the multi-line environments of amsmath is the same irrespective of the visual width of the display and that this feature is an infelicity. The only reason is because the underlying halign is full-width and it was difficult to fix. Seeing advice to 'patch' empheq to reintroduce the behavior seems incorrect to me. Commented Sep 5, 2016 at 13:26

You must log in to answer this question.

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