Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LaTeX: How to make a fullpage vertical rule on every page?

I'm using LaTeX and I would like to have vertical rule along left side of page, topmargin to bottommargin, 0.5in from the left edge of the page. I want this on every page, so I assume that means it must somehow be tied to the header or the footer?

I've made no progress at all, so I need help with (1) making the full-length rule itself and (2) making it happen automatically on every page of the document.

Can someone tell me how to do that?

like image 702
Herbert Sitz Avatar asked Jun 06 '10 22:06

Herbert Sitz


People also ask

How do you make a vertical line in LaTeX?

The “%” character is used to specify a line tag within it and create a vertical line using the “\vert” tag. Add the “$” sign before and after the “\vert” command to specify a single line.

How do you add a line across the page in LaTeX?

When you want to create a horizontal line in LaTeX of any length and thickness, the \rule command is the easiest one to use. Simply type \rule{length}{thickness} with your chosen line length and thickness in the place of the two placeholder words in the example.

How do you draw a line in LaTeX?

There are a variety of ways to make lines and boxes in LaTeX. The most basic is to make a horizontal rule using \hrule. \hrule makes a new line, and fills it up with a horizontal line. If you don't want an entire line, you can use \hrulefill, as in .


3 Answers

I got a working answer to my question on the Latex Community forum: http://www.latex-community.org/forum/viewtopic.php?f=5&t=9072&p=34877#p34877

The answer I got uses the 'Background' package and this code:

\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}

Works great and was easy to adjust to put one vrule in left margin area and one in the right margin area.

like image 83
Herbert Sitz Avatar answered Sep 22 '22 06:09

Herbert Sitz


There could be a LaTeX package to do this for you, but I'm more of a TeX person, so I tried to come up with a TeX solution (not always the best idea to mix plain TeX with LaTeX but I think I have it working).

Try this. Box 255 is the box register that TeX places the page contents into before the page is output. What I've done is taken the existing output routine, and changed it to insert into box 255: a 0-height, 0-width infinitely shrinkable-but-overflowing set of boxes containing a rule that is the height of the page, 0.4pt thick and with any luck, half an inch away into the left. The existing contents of box 255 is then added after this rule. Then I call the previous output routine which outputs the page (which now includes a rule), and also the headers and footers.

\newtoks\oldoutput
\oldoutput=\expandafter{\the\output}%
\output{%
    \setbox255\vbox to 0pt{%
        \hbox to 0pt{%
            \vsize\ht255%
            \vbox to \ht255{%
                \vss
                \hbox to -0.5in{%
                    \hss
                    \vrule height \ht255 width 0.4pt%
                }%
            }\hss
        }\vss
        \box255%
    }%
    \the\oldoutput
}%

Put it before your \begin{document} command. This might not solve your problem completely, but hopefully it should get you started. Here's a great page for learning about TeX primitives and built-in things.

like image 39
dreamlax Avatar answered Sep 19 '22 06:09

dreamlax


Have a look at the eso-pic package. From memory, what you want would look like this:

\AddToShipoutPicture{%
    \setlength\unitlength{1in}%
    \AtPageUpperLeft{%
        \put(0.5,\topmargin){\vrule width .5pt height \textheight}%
    }%
}

It's not clear in your question if you want the line to span the text area or the whole paper height. Depending on the case, you have to replace \topmargin and \textheight by the correct values, either 0pt or whatever your top margin is, or by \paperheight. See the geometry package if you don't already use it for how to control those dimensions.

like image 43
Damien Pollet Avatar answered Sep 19 '22 06:09

Damien Pollet