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.

In the code:

\documentclass{article}
\usepackage[framemethod=default]{mdframed}
\newmdenv[backgroundcolor=red]{tBox}
\newmdenv[leftmargin=1cm,linecolor=blue]{aBox}
\begin{document}
\begin{aBox}\begin{tBox}text\end{tBox}text\end{aBox}
\end{document}

enter image description here

the leftmargin of the aBox environment affects the leftmargin of the tBox environment: is this expected?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

I don't know if the package author (Marco Daniel) intended nested mdframed environments to work this way, but it seems that the inner environment simply inherits the settings of the outer environment and then adds its own settings on top of that. If you don't want the inner environment to be (additionally) indented, add leftmargin=0cm to its specification.

\documentclass{article}
\usepackage[framemethod=default]{mdframed}
\newmdenv[leftmargin=0cm,backgroundcolor=red]{tBox}
\newmdenv[leftmargin=1cm,linecolor=blue]{aBox}
\begin{document}
\begin{aBox}\begin{tBox}text\end{tBox}text\end{aBox}
\end{document}

enter image description here

share|improve this answer
    
Interesting. I thought it would be the behaviour by default. –  pluton Sep 3 '12 at 20:11
2  
@pluton: No. \newmdenv passes the optional argument to setkeys which works also for nested environments. –  Marco Daniel Sep 4 '12 at 6:16

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.