如何在文档的每一页上画一条垂直线?

如何在文档的每一页上画一条垂直线?

我想在文档中每个奇数页的左侧和每个偶数页的右侧绘制一条垂直线。有没有实现此功能的说明?

答案1

这会0.5\marginparsep在文本区域的左侧或右侧绘制一条线。

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

相关内容