[Tex/LaTex] Putting a bar in the margin

marginsrules

I sometimes want to give examples in a document I am writing. Because these examples are quite general it could be difficult for readers to see the difference between the examples and the theoretical analysis. Therefore I want to put a long vertical bar (that spans the entire example) in the margin indicating the text next to it is an example. It could be that the example uses two pages or more.

Is there any helpful package to do this. An environment would be fine. Something like this:

\begin{example}
...
\end{example}

Other suggestions to indicate the difference are welcome too. First I thought using a different background color. But I want to keep the document printable in Black/White and reading text with a gray background isn't that easy. A horizontal line at the begin and end is also an option but after two pages people could get confused.

Best Answer

The framed package provides a leftbar environment that does something like what you want:

enter image description here

\documentclass{article}
\usepackage{framed,lipsum}
\begin{document}
\lipsum[1]
\begin{leftbar}
This is a test.
\end{leftbar}
\lipsum[2]
\end{document}
Related Question