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.

Before I get to many of "don't do this as it does not look good", I have two modes of my documents:

  1. Final mode: where there is ONLY one level of nested mdframed
  2. Review mode: where there are numerous levels of nested mdframed, each one indicating information needed during the review process relevant to the text within the mdframed.

So, this requested usage is ONLY for my review mode.

The code below produces

enter image description here

But, Un-commenting out the two lines in the code yields

LaTeX Error: Too deeply nested.

I would like to get a larger number of nesting?

Code:

\documentclass{article}
\usepackage{xcolor}
\usepackage{mdframed}
\begin{document}
\begin{mdframed}[frametitle={Outer Title 1},backgroundcolor=orange!25]
    \begin{mdframed}[frametitle={Inner Title 2},backgroundcolor=cyan!25]
        \begin{mdframed}[frametitle={Inner Title 3},backgroundcolor=yellow!25]
            %\begin{mdframed}[frametitle={Inner Title 4},backgroundcolor=green]
            %\end{mdframed}
        \end{mdframed}
    \end{mdframed}
\end{mdframed}
\end{document}
share|improve this question
1  
You need to increase the number of list levels defined. Simply loading enumitem would do it, but there's also a way to do it without loading a heavy package. –  Paul Gessler Feb 27 at 3:20
    
@PaulGessler: Dammnn!! That works. BUT I am already including enumitem in my actual use case, that means that this is NOT going to solve my real problem... –  Peter Grill Feb 27 at 3:22
    
So you have additional nesting in your actual usage that puts you once again over the nesting limit? –  Paul Gessler Feb 27 at 3:24
    
@PaulGessler: Seems I can nest up to depth of 9 with enumitem, but I don't think I am exceeding that level. Back to figuring out what is going on in my actual use case. BTW, I think your suggestion is an answer. –  Peter Grill Feb 27 at 3:27
1  
@PaulGessler The answer - just not to the question? –  cfr Feb 27 at 3:37

1 Answer 1

up vote 7 down vote accepted

mdframed.sty has

\ifnum\mdf@envdepth >\tw@\@toodeep\else

in the definition of \mdf@preenvsetting and this prevents more than three levels of nesting. You can change this with a patch to the command:

\documentclass{article}
\usepackage{xcolor}
\usepackage{xpatch}
\usepackage{mdframed}
\makeatletter
\xpatchcmd{\mdf@preenvsetting}
  {\mdf@envdepth >\tw@}
  {\mdf@envdepth >20}
  {}
  {}
\makeatother
\begin{document}
\begin{mdframed}[frametitle={Outer Title 1},backgroundcolor=orange!25]
    \begin{mdframed}[frametitle={Inner Title 2},backgroundcolor=cyan!25]
        \begin{mdframed}[frametitle={Inner Title 3},backgroundcolor=yellow!25]
            \begin{mdframed}[frametitle={Inner Title 4},backgroundcolor=green]
              \begin{mdframed}[frametitle={Inner Title 5},backgroundcolor=magenta!20]
                \begin{mdframed}[frametitle={Inner Title 6},backgroundcolor=olive!20]
                  \begin{mdframed}[frametitle={Inner Title 7},backgroundcolor=red!80!black]
                    \begin{mdframed}[frametitle={Inner Title 8},backgroundcolor=gray!50]
                      \begin{mdframed}[frametitle={Inner Title 9},backgroundcolor=blue!40]
                      \end{mdframed}
                    \end{mdframed}
                  \end{mdframed}
                \end{mdframed}
              \end{mdframed}
            \end{mdframed}
        \end{mdframed}
    \end{mdframed}
\end{mdframed}
\end{document}

enter image description here

share|improve this answer

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.