I want to draw a vertical line on the left of every odd-numbered page and on the right of every even-numbered page in a document. Is there a preamble to do this?
Asked
Active
Viewed 875 times
3
1 Answers
1
This draws a line 0.5\marginparsep to the left or right of the text area.
\documentclass{report}
\usepackage{everypage}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\usepackage{lipsum}% MWE only
\AddEverypageHook{\tikz[remember picture,overlay]{%
\ifodd\value{page}\draw ($(current page text area.north west)+(-0.5\marginparsep,0pt)$)
-- ($(current page text area.south west)+(-0.5\marginparsep,0pt)$);
\else\draw ($(current page text area.north east)+(0.5\marginparsep,0pt)$)
-- ($(current page text area.south east)+(0.5\marginparsep,0pt)$);
\fi}}
\begin{document}
\lipsum [1-16]
\end{document}
John Kormylo
- 79,712
- 3
- 50
- 120
backgroundpackage can do this very easily. – Alan Munn Feb 14 '17 at 20:37fancyhdr) and put it e.g. astikzpictureinto one head (the sledgehammer-to-crack-a-nut-version). – TeXnician Feb 14 '17 at 20:50