# Adding vertical lines to each side of a paragraph

How can I add vertical lines to each side of a paragraph?

To illustrate, what I need is:

 some paragraphs...

|My paragraph begins|
|here and goes like |
|this... ~~~~~~~~~~~|
|~~~~~~~~~~~~~~~~~~~|
|~~~~~~~~~~~~~~~~~~~|
|~~~~~~~~~~~~~~~~~~~|
|~~~~~~~~~~~~~~~~~~~|
--------------------- <- Here is a page break
|~~~~~~~~~~~~~~~~~~~|
|~~~~~~~~~~~~~~~~~~~|
|~~~~~~~~~~~~~~~~~~~|
|~~~~~~~~~~~~~~~~~~~|
|The paragraph ends |
|here.              |

Some other paragraphs...


I could not use any tabular or boxing commands since they don't allow page breaks inside.

-
do you want the vertical lines in the margin or as in Gonzalo's answer inside the text area? –  jfbu Dec 10 '12 at 16:43
@jfbu my answer now includes both options. –  Gonzalo Medina Dec 10 '12 at 17:24

You can use the mdframed package; a little example:

\documentclass{article}
\usepackage{mdframed}
\usepackage{lipsum}% just to generate text for the example

\newmdenv[
topline=false,
bottomline=false,
skipabove=\topsep,
skipbelow=\topsep
]{siderules}

\begin{document}

\lipsum[4]
\begin{siderules}
\lipsum[1-5]
\end{siderules}
\lipsum[4]

\end{document}


Here's a simplemodification placing the rules in the margin (now the text width inside the environment is equal to the default \textwidth):

\documentclass{article}
\usepackage{mdframed}
\usepackage{lipsum}% just to generate text for the example

\newmdenv[
topline=false,
bottomline=false,
skipabove=\topsep,
skipbelow=\topsep,
leftmargin=-10pt,
rightmargin=-10pt,
innertopmargin=0pt,
innerbottommargin=0pt
]{siderules}

\begin{document}

\lipsum[4]
\begin{siderules}
\lipsum[1-5]
\end{siderules}
\lipsum[4]

\end{document}


-
the first paragraphs in both cases are not indented, is this an after-effect of the use of mdframed? –  jfbu Dec 10 '12 at 17:29
@jfbu yes, apparently the first line of the first paragraph is not indented by design. –  Gonzalo Medina Dec 10 '12 at 17:37
@jfbu to get the first line indented, one can add \mbox{}\indent right after \begin{siderules}. –  Gonzalo Medina Dec 10 '12 at 17:49
That's what I was really looking for. Thank you so much.. –  Alper Dec 11 '12 at 12:22

With results similar to Gonzalo's answer but made with tcolorbox.

\documentclass{article}
\usepackage{lipsum}% just to generate text for the example

\usepackage[most]{tcolorbox}

\newtcolorbox{tcbsiderules}[1][]{blanker, breakable,
left=3mm, right=3mm, top=1mm, bottom=1mm,
borderline vertical={1pt}{0pt}{black},
before upper=\indent, parbox=false, #1}

\begin{document}

\lipsum[1]
\begin{tcbsiderules}[oversize]
\lipsum[2-4]
\end{tcbsiderules}
\begin{tcbsiderules}
\lipsum[5-7]
\end{tcbsiderules}
\lipsum[8]

\end{document}


-
I get the error: I do not know the key '/tcp/borderline vertical', to which you passed '{1pt}{0pt}{black}', and I am going to ignore it. Perhaps you misspelled it. –  macmadness86 Jul 27 at 12:00
@macmadness86 You need to update tcolorbox. According its documentation, borderline vertical was added on 20-Oct-2014. –  Ignasi Jul 27 at 16:02
Ok I see. I will probably not be able to use your option then, because I unfortunately cannot update the system (yet). Thanks for identifying the problem though! –  macmadness86 Jul 27 at 16:34
@macmadness86: If you don't want to update your system, just install tcoorbox.sty and ...code.tex files from ctan in your working folder. It's not the correct solution, but will work until you update the system. –  Ignasi Jul 27 at 17:51