views:

278

answers:

3

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?

+1  A: 

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.

dreamlax
Thanks very much. I couldn't quite get it to work as written. If I compiled it in simple example doc I got errors I couldn't debug. Strangely, if I put this code in preamble of document where I was already using the 'background' solution I posted about myself, this code puts a line at the extreme left edge of the text area (i.e., at left edge of paragraph having indent of 0). I.e., it runs exactly along left edge of textarea, with height of textheight. If I comment out the background lines then I again get compile errors. I will save this code to grok at some future time. Thanks!
Herbert Sitz
@Herbert Sitz: Sorry about that, I put the `\hss` on the wrong side of the `\vrule`. Not sure why you're getting errors, it works fine for me for your lipsum test case.
dreamlax
@dreamlax: Not sure what problem was, but your code is working fine now. I gather that your solution is specially geared to draw vertical line that has top and bottom equal to top and bottom of 'textarea'. Would it be easy to modify to have it go up to top of header area and down below footer area? If not trivial, don't worry about it. Thanks again.
Herbert Sitz
@Herbert Sitz: Not trivially, it can be done. The `\vrule height xxx` can be set to anything, `\ht255` just means the height of the page (or partial page if it wasn't completely full when it was ejected); however your solution is much more elegant anyway.
dreamlax
+2  A: 

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.

Herbert Sitz
A: 

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.

Damien Pollet