2

Consider the following MWE:

\documentclass{article}
\usepackage{amsthm}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum} 
%\usepackage[parfill]{parskip}

\newtheorem{theo}{Theorem}
\surroundwithmdframed[outerlinewidth=0.5pt,
  innerlinewidth=0.5pt,
  middlelinewidth=1.5pt,
  middlelinecolor=white,
  innertopmargin=0]{theo}

\begin{document}
\lipsum[4]

\begin{theo}
\lipsum[4]
\end{theo}

\lipsum[4]
\end{document}

Everything looks great: there's a nice inner margin for the theorem and the spacing above and beneath are beautifully equal.

Now, I'd like to use the parskip package, but when I enable it, I get this ugly result:

Messed up spacing.

I could try to tweak all these margins seperately and see what looks best (I'd for example use innertopmargin=12pt), but that doesn't seem like a great solution in the long term.

How can I get the previous correct spacing back?

3
  • replace innertopmargin=0 with innertopmargin=\topskip
    – touhami
    Commented Sep 26, 2015 at 20:35
  • @touhami: The theorem being displayed partly outside of the box is only one part of the problem. There's also the space between the text and the box that isn't the same above and below anymore. I can try to tweak all these margins seperately and see what looks best (I'd for example use innertopmargin=12pt), but that doesn't seem like a great solution in the long term to me.
    – Jeroen
    Commented Sep 26, 2015 at 20:40
  • 1

1 Answer 1

1

Using mdfsetup instead of surroundwithmdframed did the trick:

\documentclass{article}
\usepackage{amsthm}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum} 
\usepackage[parfill]{parskip}

\mdfsetup{
    outerlinewidth=0.5pt,
    innerlinewidth=0.5pt,
    middlelinewidth=1.5pt,
    middlelinecolor=white,
    innertopmargin=\topskip,
    skipabove=\baselineskip,
    skipbelow=0,
    nobreak=true
}

\newmdtheoremenv{theo}{Theorem}

\begin{document}
\lipsum[4]

\begin{theo}
\lipsum[4]
\end{theo}

\lipsum[4]
\end{document}

Nice spacing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .