Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

mdframed parindent

\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}
share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

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: enter image description here

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.

share|improve this answer
add comment

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

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.