我有这个文档,它在开头添加了一个空白页,在结尾添加了两个空白页 - 这是为什么?我该如何删除它们?
因此,我最终得到了 5 页,而不是 2 页!
\documentclass{article}
\usepackage[paperheight=20.0mm, paperwidth=50.0mm, layoutheight=20.0mm, layoutwidth=50.0mm, layoutvoffset=0mm, layouthoffset=0mm, margin=0pt, includeheadfoot, showframe=false, showcrop=false]{geometry}
\usepackage{forloop}
\usepackage{fmtcount}
\usepackage[first=1, last=2147483647, seed=28112018, counter=serialnumber]{lcg}
\newcounter{numpages}
\usepackage{tikz}
\newcommand{\mypic}[2]{
\rand
\begin{tikzpicture}[remember picture, overlay]
\node (thispage) [shape=rectangle, fill=lightgray, minimum height=\paperheight, minimum width=\paperwidth, anchor=south west] at (current page.south west) {};
\node[anchor=south] at (thispage.center) {\tiny bg picture here}; %\includegraphics[width=\paperwidth, height=\paperheight]{dummy.png}};
\node at (thispage.center) {\decimal{#2} -- \padzeroes[10]{\decimal{#1}}};
\end{tikzpicture}
\newpage
}
\begin{document}
%\clearpage\thispagestyle{empty} % won't do much
\forloop{numpages}{1}{\value{numpages} < 3}{\mypic{serialnumber}{numpages}}
%\forloop{numpages}{1}{\value{numpages} < 11}{\mypic{serialnumber}{numpages}}
\end{document}
答案1
多余的页面是由于页眉和页脚无法打印。别忘了运行两次。
\documentclass{article}
\usepackage[paperheight=20.0mm, paperwidth=50.0mm, layoutheight=20.0mm, layoutwidth=50.0mm, layoutvoffset=0mm, layouthoffset=0mm, margin=0pt, noheadfoot, showframe=false, showcrop=false]{geometry}
\usepackage{forloop}
\usepackage{fmtcount}
\usepackage[first=1, last=2147483647, seed=28112018, counter=serialnumber]{lcg}
\newcounter{numpages}
\usepackage{tikz}
\newcommand{\mypic}[2]{
\rand
\begin{tikzpicture}[remember picture, overlay]
\node (thispage) [shape=rectangle, fill=lightgray, minimum height=\paperheight, minimum width=\paperwidth, anchor=south west] at (current page.south west) {};
\node[anchor=south] at (thispage.center) {\tiny bg picture here}; %\includegraphics[width=\paperwidth, height=\paperheight]{dummy.png}};
\node at (thispage.center) {\decimal{#2} -- \padzeroes[10]{\decimal{#1}}};
\end{tikzpicture}
\newpage
}
\begin{document}
%\clearpage\thispagestyle{empty} % won't do much
\forloop{numpages}{1}{\value{numpages} < 3}{\mypic{serialnumber}{numpages}}
%\forloop{numpages}{1}{\value{numpages} < 11}{\mypic{serialnumber}{numpages}}
\end{document}
答案2
使用时includeheadfoot
,文本高度会减小以便为它们腾出空间,因此您的图片会变得太大而无法放入页面中,并且在使用图片之前页面顶部的断点。
使用选项也没有多大意义layout...
,因为您指定了相同的页面宽度和高度。
还应小心宏中未受保护的空间。
您考虑过使用吗standalone
?
\documentclass{article}
\usepackage[
paperheight=20.0mm,
paperwidth=50.0mm,
margin=0pt,
]{geometry}
\usepackage{forloop}
\usepackage{fmtcount}
\usepackage[first=1, last=2147483647, seed=28112018, counter=serialnumber]{lcg}
\newcounter{numpages}
\usepackage{tikz}
\newcommand{\mypic}[2]{% <--- Here
\rand
\begin{tikzpicture}[remember picture, overlay]
\node (thispage) [
shape=rectangle,
fill=lightgray,
minimum height=\paperheight,
minimum width=\paperwidth,
anchor=south west
] at (current page.south west) {};
\node[anchor=south] at (thispage.center) {\tiny bg picture here};
%\includegraphics[width=\paperwidth, height=\paperheight]{dummy.png}};
\node at (thispage.center) {\decimal{#2} -- \padzeroes[10]{\decimal{#1}}};
\end{tikzpicture}% <--- Here
\newpage
}
\pagestyle{empty}
\begin{document}
\forloop{numpages}{1}{\value{numpages} < 3}{\mypic{serialnumber}{numpages}}
\end{document}