# Paragraph indenting in an mdframed environment

I'm using the mdframed package and I've defined my own environment. But it seems that paragraph indentation doesn't work inside a mdframed environment.

I've used the settings option of mdframed to set parindent inside but it doesn't seem to work. However when I explicitly add \setlength{\parindent}{\defparindent}, which is a rather ugly solution, it indents the first line too a little bit. So either way this whole thing is not okay.

How can I tell my singleframed environment to set \parindent inside itself?

\documentclass{article}

%\usepackage{lipsum}

\usepackage[framemethod=tikz,%
innerleftmargin=\parindent,%
skipabove=0.6\baselineskip,%
skipbelow=0.6\baselineskip,%
innertopmargin=0.4\baselineskip,%
innerbottommargin=0.4\baselineskip]{mdframed}

\newlength{\defparindent}
\setlength{\defparindent}{\parindent}

% The singleframed environment
\newmdenv[linewidth=0.4pt,%
linecolor=black,%
backgroundcolor=white,%
settings={\setlength{\parindent}{\defparindent}}]{singleframed}

\begin{document}

\begin{singleframed}
qwerty

qwerty
\end{singleframed}

\begin{singleframed}
\setlength{\parindent}{\defparindent}
qwerty

qwerty
\end{singleframed}

\end{document}


I wasn't able to use the settings provided by mdframed. So I just defined a new enviroment. I think for changing it in mdframed you would need to patch package internals. Anyway this Solution has no problem with additional spaces.

\documentclass{article}

%\usepackage{lipsum}

\usepackage[framemethod=tikz,%
innerleftmargin=\parindent,%
skipabove=0.6\baselineskip,%
skipbelow=0.6\baselineskip,%
innertopmargin=0.4\baselineskip,%
innerbottommargin=0.4\baselineskip]{mdframed}

\newlength{\defparindent}
\setlength{\defparindent}{\parindent}

% The singleframed environment
\newmdenv[linewidth=0.4pt,%
linecolor=black,%
backgroundcolor=white]{singleframed}

\newenvironment*{singleframedindent}{\begin{singleframed}\setlength{\parindent}{\defparindent}\ignorespaces}{\end{singleframed}}
\begin{document}

\begin{singleframedindent}
qwerty\\
qwerty

qwerty
\end{singleframedindent}

\end{document}


Result is:

You wouldn't have any problem with the space in your example if you would do:

\begin{singleframed}
\setlength{\parindent}{\defparindent}%
qwerty

qwerty
\end{singleframed}


The new line after setlength is the cause for the additional space. By using the comment tag you don't have any problems.

With the current version on github (upload to CTAN today) you will get the following output of your example:

• An official patch is of cause better than my solution ;) great delay between "bug report" and patch! – someonr Jan 9 '12 at 19:08
• Now I'm in a bit of trouble which answer should I accept. @someonr's answer is great, but I think I'm going to use your new code, Marco. Any idea when is it going to make it in TeX Live? – szantaii Jan 9 '12 at 19:11
• @szantaii: Accept the answer of someonr. He found a quick solution. – Marco Daniel Jan 9 '12 at 19:14
• I would accept Marco Daniel Solution. According to here (meta.SX) you should "accept the answer that you found to be the most helpful to you, personally." – someonr Jan 9 '12 at 19:24
• @MarcoDaniel With 1.9b, it does not work. – Colas Nov 25 '15 at 19:25