我正在尝试将一些 pdf 页面插入到我的 LaTeX 文档中并对它们进行编号。
到目前为止,我有以下 tex 文件:
\documentclass[10pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{pdfpages}
\usepackage{pdflscape}
\begin{document}
\section{Test Section}
Test Vertical, number bottom
\clearpage
\begin{landscape}
\includepdf[pages=1,landscape=true, scale=0.9,pagecommand=\section{Task Sheet}]{task_template.pdf}
\includepdf[pages=2,landscape=true, scale=0.9,pagecommand={}]{task_template.pdf}
\end{landscape}
\end{document}
这样可以正确旋转页面和 PDF,但页码与 PDF 左侧对齐并旋转。如何更改此设置,使页码与纵向页面位于同一位置(底部中间)。
答案1
您可以加载包scrlayer
和scrhack
。然后您可以声明一个包含页码的图层和一个包含横向页面的图层页面样式。
\documentclass[10pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{pdfpages}
\usepackage{pdflscape}
\usepackage{scrlayer}
\usepackage{scrhack}
\DeclareNewLayer[
background,
textarea,
addwidth=\footskip,
addwidth=\footheight,
contents=\hfill%
\rotatebox{90}{\parbox{\layerheight}{\centering\pagemark}}
]{lscape.foot}
\DeclareNewPageStyleByLayers{lscape}{lscape.foot}
\begin{document}
\section{Test Section}
Test Vertical, number bottom
\clearpage
\begin{landscape}
\includepdf[pages=1,landscape=true, scale=.9,pagecommand=\section{Task Sheet}\thispagestyle{lscape}]{example-image-a4-landscape.pdf}
\includepdf[pages=1,landscape=true, scale=0.9,pagecommand={\thispagestyle{lscape}}]{example-image-a4-landscape.pdf}
\end{landscape}
\end{document}
结果:
您还可以使用包typearea
来更改纸张方向:
\documentclass[10pt,
letterpaper% <- paper size as class option
]{article}
\usepackage[usegeometry]{typearea}% load before geometry
\usepackage[margin=1in]{geometry}
\usepackage{pdfpages}
\newcommand*{\useportrait}{%
\cleardoublepage
\KOMAoptions{paper=portrait,DIV=current}%
\newgeometry{margin=1in}%
}
\newcommand*{\uselandscape}{%
\cleardoublepage
\KOMAoptions{paper=landscape,DIV=current}%
\newgeometry{margin=1in}%
}
\begin{document}
\section{Test Section}
Test Vertical, number bottom
\uselandscape
\KOMAoptions{paper=landscape,DIV=current}
\newgeometry{margin=1in}
\includepdf[pages=1, scale=0.9,pagecommand=\section{Task Sheet}]{example-image-a4-landscape.pdf}
\includepdf[pages=1, scale=0.9,pagecommand={}]{example-image-a4-landscape.pdf}
\useportrait
\section{Second Test Section}
Test Vertical, number bottom
\end{document}