GeneralHow to place fullpage vertical rule in margin on every page?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
hesitz
Posts: 12
Joined: Mon Jun 07, 2010 2:32 am

How to place fullpage vertical rule in margin on every page?

Post by hesitz »

I have a document where I would like a narrow vertical rule running the length of the page about 0.5 in from left edge of the paper. I would like for this rule to appear automatically on every page, so I assume it somehow needs to be tied to a header or footer.

I'm a LaTeX newbie and I've done a lot of searching but not making any progress. Can anyone help? Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

How to place fullpage vertical rule in margin on every page?

Post by gmedina »

Hi,

there are several options. You could try, for example, the background package. A little example (addapt it according to your needs):

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{background}
\usepackage{lipsum}% just to generate filler text for the example
\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{black}
\SetBgContents{\rule{.4pt}{\paperheight}}
\SetBgHshift{-9cm}
\begin{document}
\lipsum[1-90]
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1,1,2,3,5,8,13,21,34,55,89,144,233,...
hesitz
Posts: 12
Joined: Mon Jun 07, 2010 2:32 am

Re: How to place fullpage vertical rule in margin on every p

Post by hesitz »

gmedian -- Thanks so much! That works great, and was easy to modify to have one rule in left margin and one in right. I don't so much like fact that it can't all be done in preamble, but I put it all in a newcommand in preamble so at least it can be turned on with a quick short command outside the preamble.

I did have someone who responded to my similar question in StackOverlow with tex code to draw the line, but it seems to have a small bug. You can view that answer here: http://stackoverflow.com/questions/2986 ... every-page
Strangely, the tex code draws a line only if I leave your background-package lines active in my document. If I comment them out the tex code gives me an error, won't compile. And even when it does compile and place a line (when background's lines are also printed) the line printed by the tex code is exactly at the left edge of the text area and goes from bottom of text area to top (i.e., height is exactly textwidth).

Thanks again.

-- Herb
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to place fullpage vertical rule in margin on every page?

Post by localghost »

There is another solution that uses the eso-pic package.

Code: Select all

Code, edit and compile here:
\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[includeheadfoot,margin=2cm]{geometry}
\usepackage{eso-pic}
\usepackage{calc}
\usepackage{blindtext}
\newlength{\leftrule}
\newlength{\rightrule}
\setlength{\leftrule}{2\leftmargin-\marginparsep}
\setlength{\rightrule}{2\leftmargin+\textwidth+\marginparsep}
\AddToShipoutPicture{%
\AtPageLowerLeft{%
\put(\LenToUnit{\leftrule},0){\rule{1pt}{\paperheight}} % Rule on the left
\put(\LenToUnit{\rightrule},0){\rule{1pt}{\paperheight}} % Rule on the right
}
}
\begin{document}
\blinddocument
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Best regards and welcome to the board
Thorsten
Post Reply