3

I'd like to mark examples, in an example environment in the text by drawing a vertical bar along the margin. I found a piece of code that uses the framed package to do this, but since the content of the environment in a box, this doesn't break across pages.

To show the example will continue on the next page, the line should extend vertically a bit further before/after the page break. That shouldn't be a problem using tikz, if one manages to place coordinates at the first/last lines of the environment and at the lines before/after each page break. It looks like Martin Scharrer was working on something like this, but I haven't found if that's ended up in a package by now…

In my case, I need support for at most one page break per environment.

  • 3
    mdframed allows frames with page breaking and I believe can be customised to only put the frame on one side if that is what you need – David Carlisle Apr 7 '13 at 12:50
3

As Davis Carlisle mentions in a comment, the mdframed package offers you a nice possibile solution, through its \newmdtheoremenv command; a little example interacting with one theorem style from amsthm:

\documentclass{article}
\usepackage[a5paper]{geometry}% just for the example
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}% just to generate text for the example

\theoremstyle{remark}
\newmdtheoremenv[
  skipabove=\topsep,
  skipbelow=\topsep,
  innertopmargin=0pt,
  innerbottommargin=0pt,
  leftmargin=-13pt,
  splitbottomskip=2ex,
  splittopskip=3ex,
  linecolor={cyan!80!black},
  topline=false,
  leftline=true,
  bottomline=false,
  rightline=false,
  innerrightmargin=0pt,
  innerlinewidth=3pt
  font=\normalfont
]{example}{Example}

\begin{document}

\lipsum[1]
\begin{example}
\lipsum[1-4]
\end{example}
\lipsum[1]

\end{document}  

enter image description here

  • Is there an adaptation for this so that the vertical line doesn't extend past the last line and start above the first line of each page? – Joel Jun 12 '16 at 0:20

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.