# mdframed even top and bottom margin for environments

I'm trying to use LaTeX for my current ODE lecture and use mdframed for a "boxed proposition" to make it easier for the reader to distinguish the formulation from the proof.

This is what I use to create the boxed environment "proposition"

\usepackage{mdframed}
\usepackage{xcolor}

\definecolor{superlightred}{HTML}{F5F5F5}
\newmdtheoremenv[backgroundcolor=superlightred]{proposition}{Satz}[chapter]


My problem is that this seems to include more spacing at the top of the proposition that at the bottom. Take a look here

The top contains almost one whole line of space, while the bottom seems a little narrow. How can I change this behaviour to even the spacing or even increase the bottom spacing?

You can adjust the spacing of your proposition environment with options passed in the first optional argument of newmdtheoremenv. Specifically, you can remove any inner margin by setting innertopmargin to 0, or to a negative value if needed. For more details, see the documentation of mdframed.

It might be important to note that other lengths in a document may influence the behavior of mdframed environments' margins. The examples below show the influence of parskip, but I don't think it's the only length that influences.

\documentclass{book}
\usepackage{amsthm}
\usepackage{mdframed}
\usepackage{xcolor}

\setlength{\parskip}{0pt}
\definecolor{superlightred}{HTML}{F5F5F5}
\newmdtheoremenv[backgroundcolor=superlightred]{proposition}{Satz}[chapter]
\newmdtheoremenv[backgroundcolor=superlightred,
innertopmargin=0pt]{notopmarginproposition}{Satz}[chapter]
\newmdtheoremenv[backgroundcolor=superlightred,
innertopmargin=-2pt]{negativetopmarginproposition}{Satz}[chapter]

\begin{document}
\chapter{}

\begin{proposition}
Here is the proposition with default settings.
\end{proposition}

\begin{notopmarginproposition}
Here is the proposition with \textnormal{\texttt{innertopmargin=0pt}}.
\end{notopmarginproposition}

\begin{negativetopmarginproposition}
Here is the proposition with \textnormal{\texttt{innertopmargin=-2pt}}.
\end{negativetopmarginproposition}

\end{document}


With the code above, where parskip is set to 0, we get: Using the same code, but changing parskip to 6pt, we get:

• Thank you, but if I set innerbottommargin = innertopmargin = 0pt I still get more space at the top. Why is this the case? In your example you don't set the innerbottommargin (it defaults to 5px). – user7802048 Dec 7 '19 at 17:14
• I know that other lengths influence how mdframed environments behave, so I'd say it's probably another length in your document. For example, if you change parskip, the margins will change. But if you want the top margin to be decreased more than what it is when it is set to 0, you can always define a negative length for innertopmargin. – Vincent Dec 7 '19 at 17:29
• I edited my answer to give some examples of how parskip influences the margins, but I think other lengths might have a similar behavior. I'm no expert, but in my experience, it's simpler to adjust the margins of mdframed environments at the end, when other lengths are fixed. – Vincent Dec 7 '19 at 18:05