How can I get multiple left-margin bars using the mdframed package? I can get a single left bar using, e.g.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sed orci quis urna volutpat tincidunt. Praesent ultrices commodo auctor. Nunc vel nulla sed arcu aliquet faucibus quis nec ante. Nam elementum neque vitae sem fringilla a euismod eros malesuada. Duis orci eros, tincidunt et venenatis at, tristique in tortor

with output

enter image description here

The motivation for this question is to format email correspondence in LaTeX. So if an email cites a previous email that cites a previous email, two left bars will be needed.. To achieve this one could try to nest the mdframed environments to get something like

enter image description here

The problem with the latter is that mdframed environment does not allow page breaks for nested environments. It means that it will break down if the cited text takes up more than a page. If the enivronment is not nested, it allows page breaks though..

More specifically, for the general case, I would like to have an environment say myframe taking an integer argument that specifies the number of left bars to use. Such that I could write, for instance

  • 1
    The issue with nested frames is nearly insolvable with the current implementation. The current implementation means that nested environments are nested vbox. Your second issue can be solved. May 24, 2013 at 8:07
  • @MarcoDaniel I am very impressed by the package..:) It seems that there are many ways to modify the behavior of the boundaries of the frames..so maybe this can be used to produce the desired effect instead? May 24, 2013 at 8:16
  • Which framemthod do you want to use? Most users are using framemethod=tikz. Related to your method, the modification must be done. May 24, 2013 at 8:28
  • I am not sure.. I have used the default so far.. Is there any differences in behavior? May 24, 2013 at 8:35
  • The behaviour isn't different (I hope) but the implementation differs. If you want to use tikz you have more possibilities. May 24, 2013 at 8:58

1 Answer 1


The following solution can be used as a starting point.

Let me start with some new keys.

The example defines some new keys for mdframed:

  1. quotelinewidth -- Set the line width of the quote line
  2. quoteleveldistance -- Set the distance between quoted lines if more than 1 quote levels are used
  3. quotelevel -- Set the level of the quotation

Coincident the tikzstyle quoteline is defined which specifies the style of quoteline. Default the color of the key middlelinecolor is used.

Here the example whereby page breaks are working as usual.

enter image description here

\usepackage[framemethod=tikz]{mdframed}%load xparse



\tikzset{quoteline/.append style={%
  line width=\mdf@quotelinewidth@length%

 \wlog{MDF-INFO: quotelevel \the\value{quotelevel}}%
 \ifcase\value{quotelevel}%level 0
 \or%level 1
     \wlog{quotelinewidth=\the\mdf@quotelinewidth@length and quoteleveldistance=\the\mdf@quoteleveldistance@length}%
 \else%more than 1 level
     \wlog{quotelinewidth=\the\mdf@quotelinewidth@length and quoteleveldistance=\the\mdf@quoteleveldistance@length}%
          \dimexpr \value{quotelevel}\mdf@quotelinewidth@length
            + \numexpr\value{quotelevel}-1\relax\mdf@quoteleveldistance@length
 \renewrobustcmd*\mdf@tikzbox@otl[2]{%one or two borders
    \foreach \x in {1,...,\value{quotelevel}} {%
       \path[transform canvas={%
             xshift=   (\x-1)*\mdf@quoteleveldistance@length
    hidealllines=true,leftline=true,%only leftline



  • Seems to be just what I was looking for.. :-) Thank you very much Marco! May 24, 2013 at 10:20
  • 1
    @HåkonHægland: Of course you can expand the code to get different colors for different levels. May 24, 2013 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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