我见过一些书,页码位于页面中间的页边注中;我认为这样可以更轻松地查找特定内容(IMHO)。有没有可能在 LaTeX 中做到这一点?
答案1
这backgound
包裹就能实现这一点。
所有页码均位于右边距
\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}
\pagestyle{empty}
\usepackage{background}
\backgroundsetup{
color=black,angle=0,opacity=1,scale=1,
position=current page.east,anchor=left,
contents={\tikz\node[fill=gray!50,align=center,text width=5ex]{\thepage};}
}
\begin{document}
%\setcounter{page}{100} % uncomment to see effect of large page number
\lipsum[1-20]
\end{document}
输出
不同面的页码
如果你希望将页码放在奇数页和偶数页的不同侧,那么你可以寻求帮助changepage
包裹:
代码
\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}
\pagestyle{empty}
\usepackage[strict]{changepage}
\usepackage{background}
\newcommand\pnum{
\begin{tikzpicture}[remember picture,overlay]
\checkoddpage
\ifoddpage
\node[fill=gray!50,align=center,text width=5ex,anchor=west]at(current page.west){\thepage};
\else
\node[fill=gray!50,align=center,text width=5ex,anchor=east]at(current page.east){\thepage};
\fi
\end{tikzpicture}
}
\backgroundsetup{color=black,angle=0,opacity=1,scale=1,contents={\pnum}}
\begin{document}
%\setcounter{page}{100} % uncomment to see effect of large page number
\lipsum[1-20]
\end{document}
答案2
和eso-pic
\documentclass[a4paper,twoside]{article}
\usepackage{eso-pic}
\usepackage{xcolor}
\usepackage{blindtext} % just for the example
\usepackage{ifoddpage}
\AddToShipoutPicture{%
\AtTextCenter{%
\checkoddpage
\ifoddpage
\put(\LenToUnit{\dimexpr.5\paperwidth-5mm\relax},0){\colorbox{gray}{\makebox[10mm][c]{\thepage}}}%
\else
\put(\LenToUnit{\dimexpr-.5\paperwidth-5mm\relax},0){\colorbox{gray}{\makebox[10mm][c]{\thepage}}}%
\fi
}}
\pagestyle{empty}
\begin{document}
\blinddocument % just for the example
\clearpage
\setcounter{page}{1000}
\blinddocument
\end{document}