我正在尝试在创建的文档中为几页添加一个框架。框架工作正常,“varioref”显示的页码错误。
\documentclass[10pt,letterpaper,notitlepage]{report}%
\usepackage[verbose=silent]{microtype} %Subliminal refinements towards typographical perfection%
\usepackage[letterpaper, left=0.50in, right=0.50in, top=0.50in, bottom=1.00in]{geometry} %add ``showframe'' to see the margins%
\usepackage{fontspec}
\usepackage{luatextra}
\defaultfontfeatures{Ligatures=TeX}
\usepackage{fontenc} % Allows the user to select font encodings%
\usepackage[dvipsnames,svgnames,x11names,table,hyperref,fixpdftex]{xcolor} % Driver independent access to several kinds of colors, tints, etcetera%
\usepackage[en-US]{datetime2}%
\usepackage[full]{textcomp} % Font families with sub-encoding%
\usepackage[inline]{enumitem} % Control layout of itemize, enumerate, description - use enumerate* for inline lists}%
\usepackage[parfill]{parskip} % Adjust paragraph spacing%
\usepackage{anyfontsize} % Lets the user select any font size i.e. \fontsize {}{}\selectfont%
\usepackage{calc} % Simple arithmatic in latex commands%
\usepackage{fancyhdr} % Custom page headers and footers%
\usepackage{graphicx} % Enhanced support for graphics % Driver independent color extentions for latex and pdflatex%
\usepackage{lastpage} % If the hyperref package is used, the references are hyperlinked to their aims. If these hyperlinks shall be suppressed, \pageref*{...} instead of \pageref{...}can be used.%
\usepackage{luacolor}
\usepackage{pgf}
\usepackage{pgfmorepages}
\usepackage[nospace]{varioref} % This package defines the commands \vref, \vpageref, \vrefrange, and \vpagerefrange for LATEX2".%
\usepackage[hidelinks]{hyperref} % Must be loaded last. It extends the functionality of all the LATEX cross-referencing commands (including the table of contents, bibliographies etc) to produce \special commands which a driver can turn into hypertext links%
\pgfpagesdeclarelayout{boxed}
{
\edef\pgfpageoptionborder{0pt}
}
{
\pgfpagesphysicalpageoptions
{%
logical pages=1,%
}
\pgfpageslogicalpageoptions{1}
{
border code=\pgfsetlinewidth{2pt}\pgfstroke,%
border shrink=\pgfpageoptionborder,%
resized width=.95\pgfphysicalwidth,%
resized height=.95\pgfphysicalheight,%
center=\pgfpoint{.5\pgfphysicalwidth}{.5\pgfphysicalheight}%
}%
}
\pgfpagesuselayout{boxed}
\pagestyle{fancy} % set page style to fancy%
\fancyfoot{} % clear the footers%
\fancyhead{} % clear the headers%
\renewcommand{\headrulewidth}{0pt} % Eliminate the head rule line%
\renewcommand{\footrulewidth}{2.0pt} % Create a separator line between the document and the footer 2.0pt wide%
\pagenumbering{arabic}%
\fancyfoot[r]{{\footnotesize \textbf{Page \thepage\ of~\pageref*{LastPage}}}}%%
\begin{document}
Start of document\vref{page 3}.
\cleardoublepage
this is page 2. \label{page 2}
\cleardoublepage
this is page three \label{page 3}
\end{document}
这将产生:文档第 4 页的开始。
如果我注释掉“\pgfpagesuselayout{boxed}”,则会显示正确的页码。无论如何,最后一页的页码都会正确地打印在每一页上。
我找不到纠正此问题的方法。这是否只是“varioref”与“pgf”和“pgfmorepages”之间的不兼容性?
- 谢谢!
杰瑞
答案1
这与 varioref 无关。正常情况\pageref
也会中断。
pgf 文档中描述了该问题以及建议的修复方法:
另一个注意事项:使用 pgfpages 会在 .aux 文件中产生错误的页码。原因是 TEX 仅在物理页面被输出时才在编写 .aux 文件时实例化页码。幸运的是,这个问题很容易解决:首先,正常排版我们的文件而不使用命令
\pgfpagesuselayout
(只需在它前面加上注释标记 %)然后,重新运行\pgfpagesuselayout
包含命令的 TEX 并添加命令\nofiles
。此命令确保 .aux 文件不被修改,这正是您想要的。
但是使用 pgfpages 并修改 shipout 只是为了获得一个框架,这有点矫枉过正。您可以使用 eso-pic 或使用带有 shipout/background 钩子的当前 LaTeX 来执行此操作(根据您的喜好调整 10pt):
\documentclass[10pt,letterpaper,notitlepage]{report}%
\usepackage{fancyhdr,lastpage}
\usepackage{tikz}
\usepackage[hidelinks]{hyperref}
\pagestyle{fancy} % set page style to fancy%
\fancyfoot{} % clear the footers%
\fancyhead{} % clear the headers%
\renewcommand{\headrulewidth}{0pt} % Eliminate the head rule line%
\renewcommand{\footrulewidth}{2.0pt} % Create a separator line between the document and the footer 2.0pt wide%
\pagenumbering{arabic}%
\fancyfoot[r]{{\footnotesize \textbf{Page \thepage\ of~\pageref*{LastPage}}}}%%
\AddToHook{shipout/background}{%
\put(0,-\paperheight){\tikz[overlay]\draw[line width=2pt](10pt,10pt) rectangle (\paperwidth-10pt,\paperheight-10pt);}}
\begin{document}
Start of document\pageref{page 3}.
\cleardoublepage
this is page 2. \label{page 2}
\cleardoublepage
this is page three \label{page 3}
\end{document}