3

I am trying to insert some pdf pages into my LaTeX document and have them numbered.

So far, I have the following tex file:

\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}

This correctly rotates the pages and the pdfs, but the page number is aligned to the left of the pdf and rotated. How do I change this so that the number is in the same location (bottom middle) as the portrait page.

Warmley
  • 31

1 Answers1

1

You could load packages scrlayer and scrhack. Then you can declare a layer containing the page number and a layer pagestyle for included landscape pages.

\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}

Result:

enter image description here

You can also use package typearea to change the paper orientation:

\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}

enter image description here

esdd
  • 85,675