First of all, I have seen and read this question it appears to be a different albeit potentially related issue.
I'm using mdframed
1.9b from 2013 with LuaLaTeX.
Now the problem I encounter can be reproduced with the following MWE.
\documentclass[a4paper,fontsize=12pt,twoside=false,onecolumn,final,openany,parskip=full,chapterprefix=false]{scrreprt}
\usepackage[framemethod=tikz]{mdframed}
\mdfsetup{nobreak=true}
\def\a{Here goes some really boring text which we use to fill the paragraph, but which is shorter than the standard lipsum and blindtext paragraph. }
\begin{document}
\chapter{chapter title}
\begin{mdframed}
some text box
\end{mdframed}
\a
\section{section title}
\begin{mdframed}
some text box
\end{mdframed}
\a
\subsection{subsection title}
\begin{mdframed}
some text box
\end{mdframed}
\a
\chapter{chapter title}
Now with some text prior to the \texttt{mdframed} environment. To show the effect of that on vertical spacing.
\begin{mdframed}
some text box
\end{mdframed}
\a
\section{section title}
Now with some text prior to the \texttt{mdframed} environment. To show the effect of that on vertical spacing.
\begin{mdframed}
some text box
\end{mdframed}
\a
\subsection{subsection title}
Now with some text prior to the \texttt{mdframed} environment. To show the effect of that on vertical spacing.
\begin{mdframed}
some text box
\end{mdframed}
\a
\end{document}
Let me show in screenshots. I have a document in which I use the mdframed
environment to refer to documentation right after the heading for a section. Now contrast the vertical position of the mdframed
boxes in the following two examples:
Now I'm not sure whether this is a matter of taste on my part, since I know LaTeX puts a lot of effort into spacing all over the place. But I find it very odd that in the first example the mdframed
box is essentially glued right to the heading, followed by the vertical skip that seems to belong to the heading; whereas in the second example the vertical spacing looks more sane.
How can I get mdframed
to yield something similar to the vertical spacing in the second example, even though the mdframed
environment comes right after the section heading? Or is there perhaps an alternative that I could use instead of mdframed
?
Edit: incidentally \begin{mdframed}[skipabove=\baselineskip]
(even 1em or 1ex instead of \baselineskip
) also has no effect right below section headings.
startcode=\leavevmode
, but on the whole I would advise to use tcolorbox.tcolorbox
introduces "badness" as every single instance introducesOverfull \hbox (10.0pt too wide) in paragraph
. So I got the feelingtcolorbox
may not be the appropriate workaround. As for the setup, I only use\tcbset{sharp corners, colback=white, colframe=black, boxrule=0.4pt}
(derived from the answer below).\parskip=full-
. Or check tex.stackexchange.com/questions/187339/… (for boxes after a sectioning command one must set the keybefore nobreak
in newer tcolorbox versions.)