[Tex/LaTex] Extra vertical space inside mdframed theorem environment

mdframedspacing

I have seen several similar questions on TeX.SE of a similar nature, but none of them seem to address my precise issue. I have been working with mdframed environments for a while. I read that there were some issues with older versions, so I updated to the latest version, 1.9b, but it seems to have introduced a spacing issue that I did not have before.

\documentclass{article}
\usepackage{amsthm}
\usepackage{mdframed}

\theoremstyle{definition}
\newmdtheoremenv{definition}{Definition}

\begin{document}

\begin{definition}
This is a definition.
\end{definition}

\end{document}

The output, zoomed in, is seen here:

enter image description here

There is more vertical space above the contents than below. This only began after I fully updated my TeX distribution, so I assume that this possibly changed how mdframed works. Any ideas? Obviously I can manually change the spacing to fix this, but I'm looking to diagnose the problem, if there is one. Thanks in advance.

Best Answer

The culprit is not mdframed but amsthm.

In fact, the following example without amsthm

\documentclass{article}
\usepackage{mdframed}

\newmdtheoremenv{definition}{Definition}

\begin{document}

\begin{definition}
This is a definition.
\end{definition}

\end{document} 

yields

enter image description here

To obtain the style you want, you can redefine the definition style in this way:

\newtheoremstyle{definition}% <name>
  {-\topsep}%                 <space above>
  {}%                         <space below>
  {\normalfont}%              <body font>
  {}%                         <indent amount>
  {\bfseries}%                <theorem head font>
  {.}%                        <punctuation after theorem head>
  {.5em}%                     <space after theorem head>
  {}%                         <theorem head spec>

MWE:

\documentclass{article}
\usepackage{amsthm}
\usepackage{mdframed}

\newtheoremstyle{definition}% <name>
  {-\topsep}%                 <space above>
  {}%                         <space below>
  {\normalfont}%              <body font>
  {}%                         <indent amount>
  {\bfseries}%                <theorem head font>
  {.}%                        <punctuation after theorem head>
  {.5em}%                     <space after theorem head>
  {}%                         <theorem head spec>
\theoremstyle{definition}
\newmdtheoremenv{definition}{Definition}

\begin{document}

\begin{definition}
This is a definition.
\end{definition}

\end{document} 

Output:

enter image description here