0001
Consectetur vestibulum dictum sagittis lacinia vehicula per urna parturient blandit parturient adipiscing imperdiet cubilia enim rhoncus praesent a eu a facilisi facilisis lobortis dui ad metus scelerisque cum faucibus。猫科动物自由地发出叫声,在产褥期发出叫声,在产褥期发出叫声,在产褥期发出叫声,在产褥期发出叫声,在产褥期发出叫声。我的 Posuere non a est scelerisque consequat ultrices vehicula ullamcorper cras aliquam etiam augue ac parturient ac a lobortis habitant at consectetur posuere placerat placerat。 Vestibulum id at ullamcorper ullamcorper nisi cursus mus a nec nam habitant elit odio a fusce himenaeos nibh gravida iaculis ullamcorper。 Nascetur suspendisse penatibus est laoreet ullamcorp tincidunt ad vestibulum lorem donec nisl ac proin mi suscipit quam ac morbi condimentum nostra gravida eu semper ultrices feugiat ad ullamcorper sodales。前庭,它悬挂在谷仓中,像猫一样,它吸收了前庭的营养,它吸收了猫 ...
0002
Rhoncus a vestibulum parturient qui qui neque qui absolute isse absolute in retium per orci a taciti vitae a scelerisque a cras vestibulum natoque feugiat curabitur arcu a。生命的滋润,从未停留在死寂的深渊,而是停留在刚刚死去的深渊,产后恢复健康,轻轻松松就能拥有美丽的容颜。 Nec a venenatis consectetur in faucibus sit vestibulum nisl ultricies nisi interdum convallis a condimentum scelerisque at nostra sit faucibus ad iaculis cubilia mattis。
答案1
这将使用fancyhdr
查询后的修改后的页码并将其放置在页面右侧。
代码假设页面数量永远不会超过 1000 页。
\documentclass{article}
\usepackage{blindtext}
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt}
\fancypagestyle{plain}{%
\fancyhf{}
\fancyhead[R]{%
\ifnum\value{page}<10\relax%
000\arabic{page}%
\else
\ifnum\value{page}<100\relax%
00\arabic{page}%
\else
0\arabic{page}%
\fi
\fi
}
}
\begin{document}
\pagestyle{plain}
\blindtext[1000]
\end{document}
答案2
这是一个基于 LuaLaTeX 的解决方案。
如果您的文档有超过 9999 页(但也少于 10000 [!] 页),只需在 Lua 函数中更改"%04d"
为。"%05d"
fourdigits
% !TeX program = lualatex
\documentclass{article}
\usepackage{lipsum} % for filler text
\usepackage{luacode} % for 'luacode' environment
\begin{luacode}
function fourdigits ( n )
tex.sprint ( string.format ( "%04d", n ) ) -- pad with leading zeros
end
\end{luacode}
\renewcommand\thepage{\directlua{fourdigits(\arabic{page})}}
\pagestyle{myheadings} % place page number in top right
\begin{document}
\section{Hello World}
\lipsum[1-20] % 20 paragraphs of filler text
\end{document}