请考虑以下 MWE:
\documentclass[12pt, landscape]{article}
\usepackage{tikz}
\usetikzlibrary{positioning,}
\usepackage[a3paper,
ignoreall,
hmargin={20mm,5mm},%
vmargin={5mm}%
]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{lastpage}
\parindent=0mm
\tikzset{
node distance = 0mm,
NL/.style args = {#1/#2}{draw, semithick, fill=gray!10,
inner sep=0mm, outer sep=0mm,
text width=#1 mm, minimum height=#2 mm,
node contents={}},
}
\newcommand\okvir{%
\begin{scope}[NL/.append style={line width=1mm, fill=none,
font=\bfseries, align=flush center}]
\node (f1) [NL=395/287];
\node (f2) [NL=40/15,
above left=of f1.south east,
node contents={ZFC}];
\node (f3) [NL=40/15,
above=of f2,
node contents={stran \thepage\ od \pageref{LastPage}}];
\node (f4) [NL=110/15,
left=of f2,
node contents={Leseni stebri terase v Varsanu}];
\node (f5) [NL=110/15,
above=of f4,
node contents={Hiša v Varsanu}];
\node (f6) [NL=35/15,
left=of f4,
node contents={\today}];
\node (f7) [NL=35/15,
above=of f6,
node contents={Merilo 1:25}];
\end{scope}
}
%---------------------------------------------------------------%
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
%---------------------------------------------------------------%
\okvir
%---------------------------------------------------------------%
\end{tikzpicture}
\begin{tikzpicture}
%---------------------------------------------------------------%
\okvir
%---------------------------------------------------------------%
\end{tikzpicture}
\end{document}
问题:
- 为什么第一页没有框架?
- 为什么页码没有增加?
答案1
您的框架在第一页上处理,因此 \thepage 为 1。但由于它太大,因此将其移至第 2 页。稍微增大 textheight 会使框架保持在第一页上。但这不会解决 \thepage 问题:它在这个地方不可靠。您应该将框架放在页眉或页脚中,或者使用 \pageref 检索页码:
\documentclass[12pt, landscape]{article}
\usepackage{tikz}
\usetikzlibrary{positioning,}
\usepackage[a3paper,
ignoreall,
hmargin={20mm,5mm},%
vmargin={5mm}%
]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{lastpage}
\parindent=0mm
\tikzset{
node distance = 0mm,
NL/.style args = {#1/#2}{draw, semithick, fill=gray!10,
inner sep=0mm, outer sep=0mm,
text width=#1 mm, minimum height=#2 mm,
node contents={}},
}
\newcounter{okvir}
\newcommand\okvir{%
\stepcounter{okvir}\label{okvir-num\number\value{okvir}}%
\begin{scope}[NL/.append style={line width=1mm, fill=none,
font=\bfseries, align=flush center}]
\node (f1) [NL=395/287];
\node (f2) [NL=40/15,
above left=of f1.south east,
node contents={ZFC}];
\node (f3) [NL=40/15,
above=of f2,
node contents={stran \pageref{okvir-num\number\value{okvir}} od \pageref{LastPage}}];
\node (f4) [NL=110/15,
left=of f2,
node contents={Leseni stebri terase v Varsanu}];
\node (f5) [NL=110/15,
above=of f4,
node contents={Hiša v Varsanu}];
\node (f6) [NL=35/15,
left=of f4,
node contents={\today}];
\node (f7) [NL=35/15,
above=of f6,
node contents={Merilo 1:25}];
\end{scope}
}
%---------------------------------------------------------------%
\advance\textheight by 3pt
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
%---------------------------------------------------------------%
\okvir
%---------------------------------------------------------------%
\end{tikzpicture}
\begin{tikzpicture}
%---------------------------------------------------------------%
\okvir
%---------------------------------------------------------------%
\end{tikzpicture}
\end{document}