答案1
在您的情况下不需要使用 TikZ,一个简单的\rule
包eso-pic
就足够了。
我认为这些东西的英文单词是“border”或“frame”。
当然,这也适用于多个页面:
\documentclass{article}
\usepackage{eso-pic}
\usepackage{mwe}% <--- for testing purpose only
\AddToShipoutPictureBG{%
\rule{1cm}{\paperheight}%
}
\begin{document}
\blindtext% <--- for testing purpose only
\end{document}
如果您希望奇数页左侧有黑线,偶数页右侧有黑线,只需\thepage
使用\ifnumodd
进行测试etoolbox
:
\documentclass{book}
\usepackage{eso-pic}
\usepackage{etoolbox}
\usepackage{mwe}% <--- for testing purpose only
\newlength{\mylen}
\setlength{\mylen}{\paperwidth}
\addtolength{\mylen}{-1cm}
\AddToShipoutPictureBG{%
\ifnumodd{\thepage}{\rule{\mylen}{0cm}\rule{1cm}{\paperheight}}{\rule{1cm}{\paperheight}}%
}
\begin{document}
\blindtext[10]% <--- for testing purpose only
\end{document}
答案2
以下是在每页左侧带有矩形的解决方案:
\documentclass{book}
\usepackage[left=2.5cm,right=2.5cm, top=3.75cm, bottom=3.5cm,a4paper]{geometry}
\usepackage[all]{background}
\usepackage{tikz}
\usepackage{changepage}
\usepackage{lipsum}
\backgroundsetup{
scale=1,
angle=0,
opacity=1,
color=black,
contents={\begin{tikzpicture}[remember picture, overlay]
\draw[fill=black] ([xshift=1cm,yshift=0cm] current page.north west) rectangle ([xshift=.0cm,yshift=0cm] current page.south west);
\end{tikzpicture}}
}
\begin{document}
\lipsum[1-27]
\end{document}
如果您希望左侧的矩形用于偶数页,右侧的矩形用于奇数页,则代码如下:
\documentclass{book}
\usepackage[left=2.5cm,right=2.5cm, top=3.75cm, bottom=3.5cm,a4paper]{geometry}
\usepackage[all]{background}
\usepackage{tikz}
\usepackage{changepage}
\usepackage{lipsum}
\backgroundsetup{
scale=1,
angle=0,
opacity=1,
color=black,
contents={\begin{tikzpicture}[remember picture, overlay]
\checkoddpage % to comment if you want only left side
\ifoddpage % to comment if you want only left side
\draw[fill=black] ([xshift=-.5cm,yshift=0cm] current page.south east) rectangle ([xshift=-0cm,yshift=0cm] current page.north east); % to comment if you want only left side
\else % to comment if you want only left side
\draw[fill=black] ([xshift=.5cm,yshift=0cm] current page.north west) rectangle ([xshift=0cm,yshift=0cm] current page.south west);
\fi % to comment if you want only left side
\end{tikzpicture}}
}
\begin{document}
\lipsum[1-27]
\end{document}
结果如下:
答案3
使用framed.sty
\usepackage{framed}
\begin{document}
\begin{leftbar}
...
\end{leftbar}