# mdframed and parskip

This seems pretty easy: how can I get a paragraph skip in an mdframed, same as outside the box? Is it somehow disabled', and if so, is there a reason for that?

Here is how it's set up, in a floating environment. Don't know if that does anything; I copied and modified the code from another post, so I don't totally know how it works.

\documentclass{report}
\usepackage{geometry}
\usepackage[parfill]{parskip}
\usepackage[framemethod=TikZ]{mdframed}
\mdfsetup{frametitlealignment=\center}
\usepackage{newfloat}

\DeclareFloatingEnvironment[fileext=frm,placement={!ht},name=Frame]{myfloat}
\newenvironment{infobox}[2][ht] {
\begin{myfloat}[#1]
\begin{mdframed}[roundcorner=10pt,frametitle={Box~X: #2},nobreak=false]}
{\end{mdframed}\end{myfloat}}

\begin{document}

\chapter{}
Hello, this is text.

Using parskip with parfill option.

\begin{infobox}{Title}
Why does this not have line skips?

I would like it to look like the rest of the document.
\end{infobox}

\end{document}


Sorry if this is a duplicate of another question, but if so I couldn't find it.

• I guess that there is no deep reason for that other than that minipages kill parskip. You can check that a simple minipage does the same. (Very nice profile pic BTW ;-) – user121799 Mar 10 '18 at 0:15
• I would advise you to use tcolorbox instead of mdframed, much better and also actively maintained - and it has an option to have the same parskip inside the box as outside. – Ulrike Fischer Mar 10 '18 at 15:57
• Wait, is there a link between mdframed and minipage? I did find a bunch of stuff about minipage, but not sure if it applies. I'll look into tcolorbox - I thought it would be too fancy for what I wanted, but at this point, it's not like mdframed is being that easy to work with. Thanks guys =) – Irene Mar 11 '18 at 4:55

As mentioned above in the comments, this seems to be related to some ad hoc choice of the creator of LaTeX. Here is a possible workaround.

\documentclass{report}
\usepackage{geometry}
\usepackage[parfill]{parskip}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usepackage{tikzpagenodes}
\usepackage{lipsum}
\tikzset{SimpleBox/.style={draw,thick,rounded corners}}

\newcommand{\SimpleBox}[2][2pt]{%
\tikz[remember picture,overlay, baseline=(Begin.base)]{%
\node[anchor=base,inner sep=0pt,outer sep=0pt] (Begin) {\strut};}#2%
\tikz[remember picture,overlay, baseline=(End.base)]{%
\node[anchor=base,inner sep=0pt,outer sep=0pt] (End) {\strut};}%
\begin{tikzpicture}[overlay,remember picture]
\path (current page text area.north west) -- (current page text area.south west)
node(WestLine)[left]{};
\path (current page text area.north east) -- (current page text area.south east)
node(EastLine)[right]{};
\begin{scope}[on background layer]
\draw[SimpleBox] (Begin.north-|WestLine) rectangle (End.south-|EastLine);
\end{scope}
\end{tikzpicture}}

\begin{document}

Hello, this is text.

Using parskip with parfill option.

\SimpleBox{
\centerline{\textbf{Box X: Title}}
Hello, this is text.

Using parskip with parfill option also works in the box (and not just out of
the box'';-).
}

\end{document}


I understand that this does not answer your question, but I hope it allows you to achieve an output similar to what you wanted.

ADDENDUM: A code that allows the box to run over one (!) page break. Relies on the pioneering work of this post.

\documentclass{report}
\usepackage{geometry}
\usepackage[parfill]{parskip}
\usepackage{refcount}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usepackage{tikzpagenodes}
\usepackage{lipsum}
\newif\ifSimpleBoxOpen\SimpleBoxOpentrue
\tikzset{SimpleBox/.style={draw,thick,rounded corners}}

\usepackage{lipsum}
\newcounter{tmp}
\newcommand\tikzmark[1]{%
\tikz[overlay,remember picture] \node (#1) {};}

\newcommand\StartBox[1][]{%
\stepcounter{tmp}%from https://tex.stackexchange.com/a/52579/121799
\tikz[remember picture,overlay, baseline=(Begin.base)]{%
\node[anchor=base,inner sep=0pt,outer sep=0pt] (Begin) {\strut};}
\label{a\thetmp}%
\ifnum\getpagerefnumber{a\thetmp}=\getpagerefnumber{b\thetmp} \else
\begin{tikzpicture}[overlay, remember picture]
\path (current page text area.north west) -- (current page text area.south west)
node(WestLine)[left]{};
\path (current page text area.north east) -- (current page text area.south east)
node(EastLine)[right]{};
\begin{scope}[on background layer,blend mode=multiply]
\ifSimpleBoxOpen
\draw[SimpleBox,#1] ( current page text area.south-|WestLine) --
(Begin.north-|WestLine) -- (Begin.north-|EastLine) --  (current page text
area.south-|EastLine);
\else
\draw[SimpleBox,#1] (Begin.north-|WestLine) rectangle (current page text
area.south-|EastLine);
\fi
\end{scope}
\end{tikzpicture}%
\fi%
}

\newcommand\EndBox[1][]{%
\tikz[remember picture,overlay, baseline=(End.base)]{%
\node[anchor=base,inner sep=0pt,outer sep=0pt] (End) {\strut};}%
\label{b\thetmp}
\ifnum\getpagerefnumber{a\thetmp}=\getpagerefnumber{b\thetmp}
\begin{tikzpicture}[overlay,remember picture]
\path (current page text area.north west) -- (current page text area.south west)
node(WestLine)[left]{};
\path (current page text area.north east) -- (current page text area.south east)
node(EastLine)[right]{};
\begin{scope}[on background layer]
\draw[SimpleBox,#1] (Begin.north-|WestLine) rectangle (End.south-|EastLine);
\end{scope}
\end{tikzpicture}
\else
\begin{tikzpicture}[overlay,remember picture]
\path (current page text area.north west) -- (current page text area.south west)
node(WestLine)[left]{};
\path (current page text area.north east) -- (current page text area.south east)
node(EastLine)[right]{};
\begin{scope}[on background layer,blend mode=multiply]
\ifSimpleBoxOpen
\draw[SimpleBox,#1] ( current page text area.north-|WestLine) --
(End.south-|WestLine) -- (End.south-|EastLine) --  (current page text
area.north-|EastLine);
\else
\draw[SimpleBox,#1] (Begin.north-|WestLine) rectangle (current page text
area.south-|EastLine);
\fi
\end{scope}
\end{tikzpicture}
\fi
}

\newcommand{\SimpleBox}[2][]{%
\StartBox[#1]%
#2\EndBox[#1]}

\begin{document}

Hello, this is text.

Using parskip with parfill option.

\SimpleBox{
\centerline{\textbf{Box X: Title}}
Hello, this is text.

Using parskip with parfill option also works in the box (and not just out of
the box'';-).
}

\lipsum[1-4]

\SimpleBox{\lipsum[5-6]}

\end{document}

• That is a very nice looking box! I'm ready to copy the code, but does it let me page break? mdframed is actually not page breaking properly for me either right now, but I hear it's supposed to. (p.s. @marmot, i like your profile pic too... always nice to meet a fellow rodent!) – Irene Mar 11 '18 at 4:57
• @Irene No, it does not. It is possible to write a code that does, using the tricks of this post, but the details would/will depend on how you want to deal with these boxes. Do you want them to be open at the bottom of the first and top of the second page or always close them? – user121799 Mar 11 '18 at 5:09
• @Irene I added a code that deals with page breaks. Currently the box is open at the bottom of the first and the top of the next page, but if you set \SimpleBoxOpenfalse instead of \SimpleBoxOpentrue`, they are closed. – user121799 Mar 11 '18 at 16:44
• Awesome, thanks! It worked, but only after I typeset it about three times (??). One of my boxes also has some issue with being closed when it should be open, but there's so much other stuff in this document that it could be interacting with anything. Not worth troubleshooting and this works. Thanks again! – Irene Mar 11 '18 at 17:06
• @Irene Thanks for letting me know. If you give me a specific example, I am confident I can fix it. And yes, you need to compile three times, because (i) there are overlays and (ii) the overlays depend on whether or not the start and end are on the same page. – user121799 Mar 11 '18 at 17:25