Featured Book

LaTeX Beginners Guide

Who is online

In total there are 26 users online :: 1 registered, 0 hidden and 25 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: Google [Bot] and 25 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

paragraph with vertical rule on the side?

Add tags LaTeX specific issues not fitting into one of the other forums of this category.

paragraph with vertical rule on the side?

Postby sfranky on Mon Dec 10th, 2007

hi everyone!
is there a way I can have a vertical rule on the left side of a paragraph? I tried with minipage but the problem is I can't figure out a way to determine the height of the rule, since the rule should depend on the height of the paragraph...Of course there's no point in doing it manually everytime..
What i have is mind is what the "changebar" package does, only I do not want it for revisioning..
thanks in advance!
sotiris
sfranky
 
Posts: 9
Joined: Thu Nov 29th, 2007

Re: paragraph with vertical rule on the side?

Postby Juanjo on Mon Dec 10th, 2007

I didn't knew the package changebar. After a quick look, I think it does exactly what you want. You can use it even if you do not plan to do revisioning.

If you finally decide to try other approach, perhaps you may find useful the following code:

Code: Select all  •  Open in writeLaTeX
\newsavebox{\mybox}
\newlength{\mydepth}
\newlength{\myheight}

\newenvironment{sidebar
}%
{\begin{lrbox}{\mybox}\begin{minipage}{\textwidth}}%
{\end{minipage}\end{lrbox}%
 \settodepth{\mydepth}{\usebox{\mybox}}%
 \settoheight{\myheight}{\usebox{\mybox}}%
 \addtolength{\myheight}{\mydepth}%
 \noindent\makebox[0pt]{\hspace{-20pt}\rule[-\mydepth]{1pt}{\myheight}}%
 \usebox{\mybox}}


This code defines an environment for writing text with a vertical rule of the left. You can change the width of the rule (1pt) and the separation from the left margin (20pt).

Put the above code in the preamble and try something like

Code: Select all  •  Open in writeLaTeX
\begin{sidebar}
 Text text text text \par
 More lines of text ....\par
 Text text text.
\end{sidebar
}


Please, take into account that this environment puts text into a minipage. This may cause problems if a page break should happen in the middle of the text, since the minipage will not be splitted.
User avatar
Juanjo
 
Posts: 656
Joined: Sat Jan 27th, 2007

Re: paragraph with vertical rule on the side?

Postby sfranky on Tue Dec 11th, 2007

thanks very much for your help!! this is exactly what I needed!
I have searched and searched over the web to find how to do this, but I couldn't.. how do you even learn to construct such things?? is there a special tutorial for this? i have looked in books and tutorials but i don't think they cover that sort of thing..
thanks again,
sotiris

ps. is it too troublesome to change the colour of the rule? eg to gray? Embarassed
sfranky
 
Posts: 9
Joined: Thu Nov 29th, 2007

Re: paragraph with vertical rule on the side?

Postby Juanjo on Tue Dec 11th, 2007

how do you even learn to construct such things?? is there a special tutorial for this? i have looked in books and tutorials but i don't think they cover that sort of thing..


This kind of things are in good books like The LaTeX Companion, by Goosens et al., A Guide to LaTeX2e, by Kopka and Daly, and, of course, LaTeX: A Document Preparation System, by Lamport. I recommend you to buy, if you can, one of these books.

is it too troublesome to change the colour of the rule? eg to gray?


Add \usepackage{color} to the preamble and insert, for example, \color[gray]{0.3} just before \rule in the definition of sidebar. Read the documentation of the color package to learn how to specify colors. You can use instead the xcolor package for a more sophisticated manipulation of colors.
User avatar
Juanjo
 
Posts: 656
Joined: Sat Jan 27th, 2007

Re: paragraph with vertical rule on the side?

Postby sfranky on Tue Dec 11th, 2007

thanks for your help!! I've seen the book you mention in my uni, and I used to look up things in there, but at that time my knowledge was even smaller and I looked for simpler things)
thaaanks!
sfranky
 
Posts: 9
Joined: Thu Nov 29th, 2007


Return to General

Who is online

Users browsing this forum: Google [Bot] and 25 guests