# Landscape and page numbers with pdfpages

I am using pdfpages to insert PDFs into a master file. Some of the PDFs are portrait and some are landscape. I am using pagecommand=\thispagestyle{plain} so that the page numbers are in sequence throughout the final document. However, on PDFs included as landscape, the page numbers appear on the left side of the page (i.e. as they would if the page were not landscape). How can I get them to appear on the bottom of the page?

MWE where one.pdf is included in portrait and two.pdf is included in landscape:

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

-
Welcome to TeX.sx! Welcome to TeX.sx! A tip: You can use backticks  to mark your inline code as I did in my edit. –  hpesoj626 Oct 21 '12 at 2:32

Using fancyhdr you can define your own page style and move the page number/counter into the appropriate position.

\usepackage{pdfpages}% http://ctan.org/pkg/pdfpages
\usepackage{fancyhdr}% http://ctan.org/pkg/fancyhdr
\fancypagestyle{mylandscape}{%
\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{\footrulewidth}{0pt}% No footer rule
}


You would then use pagecommand=\thispagestyle{mylandscape}. Example output with one.pdf (1 page portrait) and two.pdf (1 page landscape):

### 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}{%
\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{\footrulewidth}{0pt}% No footer rule
}
\begin{document}
\lipsum[1-5]
\includepdf[noautoscale,landscape,pagecommand=\thispagestyle{mylandscape}]{two.pdf}
\end{document}

-
This solution isn't working for me. Could you show us how the mylandscape command was included on the page? I am using pdflscape package and begin/end{landscape} to rotate my pages. The solution you have proposed places the page number in bold towards left of the page, not center. –  cryptic0 Apr 17 '13 at 23:52
@cryptic0: I've added the MWE that creates the image in the answer. –  Werner Apr 18 '13 at 2:37
Thank you for a quick response and the code. What is the function of two.pdf? –  cryptic0 Apr 18 '13 at 2:41
@cryptic0: The OP mentioned a separate document which was set in landscape format. In my case, I created a dummy document two.tex which, when compiled with pdflatex, creates two.pdf. –  Werner Apr 18 '13 at 2:44
What if I didn't want that. Could I then just use \thispagestyle{mylandscape}`? –  cryptic0 Apr 18 '13 at 2:55