我需要创建一个 latex 模板,它将生成 PDF,每页左边距有两个零(MWE 在下面提供),最后一页有三个零。问题出在最后一页,因为它没有给出预期的输出。有关此内容的说明应仅写在序言中。
\documentclass[12pt]{article}
\usepackage{blindtext}
\usepackage{eso-pic, rotating, graphicx}
\AddToShipoutPicture{\put(20,410){\rotatebox{0}{0}}}
\AddToShipoutPicture{\put(20,400){\rotatebox{0}{0}}}
\AddToShipoutPicture{\put(20,390){\rotatebox{0}{0}}}
\begin{document}
\blindtext[8]
\end{document}
答案1
该解决方案使用 lastpage 和 refcount 包。
\documentclass[12pt]{article}
\usepackage{blindtext}
\usepackage{eso-pic, rotating, graphicx}
\usepackage{lastpage,refcount}
\AddToShipoutPicture{\put(20,410){\rotatebox{0}{0}}}
\AddToShipoutPicture{\put(20,400){\rotatebox{0}{0}}}
\AddToShipoutPicture{\ifnum\getpagerefnumber{LastPage}=\value{page}\put(20,390){\rotatebox{0}{0}}\fi}
\begin{document}
\blindtext[8]
\end{document}