我使用pdfpages
将 PDF 插入主文件。一些 PDF 是纵向的,一些是横向的。我使用pagecommand=\thispagestyle{plain}
这种方式是为了让页码在整个最终文档中按顺序排列。但是,在横向包含的 PDF 上,页码显示在页面的左侧(即,如果页面不是横向的,页码就会显示在页面的左侧)。我怎样才能让它们显示在页面的底部?
MWEone.pdf
包含在纵向和two.pdf
横向中:
\documentclass[12pt,english]{article}
\usepackage{pdfpages}
\includepdfset{pagecommand=\thispagestyle{plain}}
\usepackage{geometry}
\begin{document}
This is the text in the master file.
\newpage{}
\includepdf[pages=-,landscape=false]{one}
\newpage{}
\includepdf[pages=-,landscape=true]{two}
\end{document}
答案1
使用fancyhdr
您可以定义自己的页面样式并将页码/计数器移动到适当的位置。
\usepackage{pdfpages}% http://ctan.org/pkg/pdfpages
\usepackage{fancyhdr}% http://ctan.org/pkg/fancyhdr
\fancypagestyle{mylandscape}{%
\fancyhf{}% Clear header/footer
\fancyfoot{% Footer
\makebox[\textwidth][r]{% Right
\rlap{\hspace{\footskip}% Push out of margin by \footskip
\smash{% Remove vertical height
\raisebox{\dimexpr.5\baselineskip+\footskip+.5\textheight}{% Raise vertically
\rotatebox{90}{\thepage}}}}}}% Rotate counter-clockwise
\renewcommand{\headrulewidth}{0pt}% No header rule
\renewcommand{\footrulewidth}{0pt}% No footer rule
}
然后您可以使用pagecommand=\thispagestyle{mylandscape}
。示例输出为one.pdf
(1 页纵向)和two.pdf
(1 页横向):
two.tex
:
\documentclass{article}
\usepackage{pdflscape,lipsum}% http://ctan.org/pkg/lipsum
\pagestyle{empty}
\begin{document}
\begin{landscape}
\lipsum[1-5]
\end{landscape}
\end{document}
one.tex
:
\documentclass{article}
\usepackage{lipsum,pdfpages,fancyhdr}% http://ctan.org/pkg/{lipsum,pdfpages,fancyhdr}
\fancypagestyle{mylandscape}{%
\fancyhf{}% Clear header/footer
\fancyfoot{% Footer
\makebox[\textwidth][r]{% Right
\rlap{\hspace{\footskip}% Push out of margin by \footskip
\smash{% Remove vertical height
\raisebox{\dimexpr.5\baselineskip+\footskip+.5\textheight}{% Raise vertically
\rotatebox{90}{\thepage}}}}}}% Rotate counter-clockwise
\renewcommand{\headrulewidth}{0pt}% No header rule
\renewcommand{\footrulewidth}{0pt}% No footer rule
}
\begin{document}
\lipsum[1-5]
\includepdf[noautoscale,landscape,pagecommand=\thispagestyle{mylandscape}]{two.pdf}
\end{document}