At the moment I'm using the {tabular} environment to distinguish examples in a document I'm writing:

\emph{Example} & [Lots of text and equations]

It makes it so that there's a nice line running down the left side of my page over the course of the example. The only problem is that it doesn't behave well with page breaks. I know the package longtable works for continuing tables onto several pages but since I have everything in one table entry, it doesn't work for me.

I realise I'm completely misusing {tabular} and am looking for an environment that will give me the same effect, but will continue the effect onto successive pages.


Two simple examples showing two possibilities: one with mdframed and the other one with tcolorbox; the advantage of these packages over framed is that they offer endless customization possibilities with a simple key=value interface:

\usepackage[a5paper,paperwidth=18cm]{geometry}% just for the example
\usepackage{lipsum}% just to generate text for the example


enlarge left by=-14pt,
overlay unbroken and first={
  anchor=north east,
  inner xsep=8pt,
  rounded corners=5pt,
  fill=white] at ([xshift=-0.2cm]frame.north west) (tit) {\strut Example:};
  line width=3pt,
  rounded corners=5pt,gray
  ] ([xshift=4pt]frame.north west) -- ([xshift=4pt]frame.south west);
overlay middle and last={
  line width=3pt,
  rounded corners=5pt,gray
  ] ([xshift=4pt]frame.north west) -- ([xshift=4pt]frame.south west);
frame code={},
interior code={},




enter image description here

The page layout was changed just for the example.

You can also take a look at the answer to Typesetting a definition for more examples and variations (the code in that answer can be easily adapted to produce the label "Example" instead of "Definition").

  • when I compile your example the last mdframe becomes funny, I believe it happens because it breaks the page. I do not know how to solve this problem. Any idea? – saldenisov Sep 6 '15 at 11:55
  • @saldenisov When I compile my example, the result is the one in the image and I don't see anything funny. Perhaps you are using some different settings? In any case, we would need to see the offending code. please consider opening a new question. – Gonzalo Medina Sep 6 '15 at 16:24
  • I've added colback=white,colframe=white and now it does what it should. – saldenisov Sep 6 '15 at 18:02

MWE using the package framed, edited to have enough text to break the page:







Want to change how thick your line is and how far from your text it's set? Add this to the preamble after you \usepackage{framed}:

  \def\FrameCommand{\vrule width 1pt \hspace{5pt}}%
  \MakeFramed {\advance\hsize-\width \FrameRestore}}%

where \vrule width Xpt (in this case, changed to 1pt) sets the thickness of your vertical rule and \hspace{Ypt}, set to 5pt here, is the space from your line to your text.

You can also use the native leftbar environment if you don't want to deal with the other formating that comes with the quotation environment. Just frame your example text with


and the same customization options in the preamble will apply.

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.