I want to use mdframed
to add a frame around a text. But the vertical spacing is not as expected. I found the following help page:
Vertical spacing problem related to the mdframed environment
The accepted answer was promising and I tested it myself, but I get a different result than the screenshot there suggests.
Here is the answer example:
\documentclass{article}
\usepackage[framemethod=1]{mdframed}
\begin{document}
\noindent Text
\begin{mdframed}
Framed
\end{mdframed}
Text
\noindent Text
\begin{mdframed}[skipbelow=-0.5em]
Framed
\end{mdframed}
Text
\end{document}
My result is:
I have mdframed
version 1.9 installed which seems to be the newest version.
Can anybody can confirm this behaviour? Even better would be a fix for the problem.
EDIT:
After AboAmmar's answer. I noticed an even stranger but perhaps related behavior of mdframed
. It allows to define a style and use it for a environment afterwards. The following example will use the skipabove
, but the skipbelow
seems to be ignored:
\documentclass{article}
\usepackage[framemethod=1]{mdframed}
\mdfdefinestyle{mystyle}{skipabove=2pt,skipbelow=-2pt}
\begin{document}
\noindent Text
\begin{mdframed}[style=mystyle]
Framed
\end{mdframed}
Text
\end{document}
Result:
The result is the same, if the skipbelow
is defined directly after \begin{mdframed}
. Only \mdfsetup{skipabove=2pt,skipbelow=-2pt}
seem to change the space after the box, but I don't want to use the setting globally.