3

Can anybody explain where the extra spacing comes from when using an align instead of a equation? And does anybody know how to remove it?

\documentclass{article}
\usepackage{amsmath}
\usepackage{mdframed}
\mdfdefinestyle{myframe}{frametitlebackgroundcolor=green}
\begin{document}
  \begin{mdframed}[style=myframe, frametitle={B}]
    \begin{equation} c^2=a^2+b^2 \end{equation}
  \end{mdframed}
  \begin{mdframed}[style=myframe, frametitle={A}]
    \begin{align} c^2 & =a^2+b^2 \\ & \geq a^2 \end{align}
  \end{mdframed}
\end{document}

enter image description here

Carucel
  • 1,035
  • 2
    You get the same behavior if you try a stock minipage instead of mdframed. The problem is that align should never be used at the start of a paragraph; a remedy is to issue \vspace{-\baselineskip} before \begin{align} (but tcolorbox is much more powerful). – egreg Mar 21 '16 at 11:29

1 Answers1

3

With tcolorbox you can use ams equation or ams algin special boxes and this gap disappears.

\documentclass{article}
\usepackage{amsmath}
\usepackage[most]{tcolorbox}
\newtcolorbox{myframe}[1][]{colbacktitle=green,coltitle=black, #1}
\begin{document}
  \begin{myframe}[title=B, ams equation]
    c^2=a^2+b^2 
  \end{myframe}
  \begin{myframe}[title=A, ams align]
    c^2 & =a^2+b^2 \\ & \geq a^2 
  \end{myframe}

  This is a very long long sentence
  \[c^2=a^2+b^2\]

  This is a very long long sentence
    \begin{align} c^2 & =a^2+b^2 \\ & \geq a^2 \end{align}
\end{document}

enter image description here

Ignasi
  • 136,588
  • 2
    Thank you! I am still looking for an explanation of the unexpected behaviour I described however, since I would like to understand the possible limitations of mdframed or align. – Carucel Mar 21 '16 at 10:58