10

This question has already been asked (How to change certain pages into landscape/portrait mode), but as a comment says, the given solution puts the page number on one of the side at with a 90° rotation:

\usepackage{pdflscape}
...
\begin{landscape}
...
\end{landscape}

I would think this might be logical if you actually print the stuff, since then you would stack it in with the portrait pages and this way you will have the page number on the same physical location, but it is quite confusing when viewing on the monitor. Is there a way to place the page number at the bottom of the page?

3 Answers 3

6

The hard way to do it would be to use:

\documentclass{article}
\usepackage{pdflscape}
\usepackage{everypage}
\usepackage{lipsum}

\newcommand{\Lpagenumber}{\ifdim\textwidth=\linewidth\else\bgroup
  \dimendef\margin=0 %use \margin instead of \dimen0
  \ifodd\value{page}\margin=\oddsidemargin
  \else\margin=\evensidemargin
  \fi
  \raisebox{\dimexpr -\topmargin-\headheight-\headsep-0.5\linewidth}[0pt][0pt]{%
    \rlap{\hspace{\dimexpr \margin+\textheight+\footskip}%
    \llap{\rotatebox{90}{\thepage}}}}%
\egroup\fi}
\AddEverypageHook{\Lpagenumber}%

\begin{document}
\begin{landscape}
\pagestyle{empty}%
\lipsum[1]
\newpage
\noindent\rule{\linewidth}{\textheight}% fill text area
\end{landscape}
\pagestyle{plain}%
\lipsum[2]
\end{document}

Then again, this will also work for multiple pages.

Note that the page hook runs after the page of formatted but before the page number is incremented. At this point the "cursor" is located 1in below and 1in to the right of the upper left corner, and must not be moved.

6
  • 2
    Why is the "hard way" better than the "easy"?
    – fbence
    Nov 14, 2015 at 8:44
  • It isn't. But it can easily be adapted to handle multiple pages. All you need is to use \AddEverypageHook and add a switch to turn it on and off. Nov 14, 2015 at 14:27
  • thanks:) just to flesh out the answer: how would that be done?
    – fbence
    Nov 14, 2015 at 17:24
  • This test will fail if the text area is perfectly square. Then again, why bother doing a square in landscape? Nov 14, 2015 at 18:28
  • What part of the code accomplishes the task? It's not clear to me. Can you add comments to the code? Thanks! Feb 26, 2018 at 16:25
12

easiest way would be to use

\begin{landscape}
\thispagestyle{empty}

....
\vfill
\raisebox{-??}{\makebox[\linewidth]{\thepage}}
\end{landscape}

adjusting the raisebox amount to position it "by eye" into the space normally used for the left margin.

Note \thepage here is "safe" as landscape forces a pagebreak with \clearpage so you do not have the usual problem about references to page numbers not being known within the document.

6

For isolated pages needing the "landscaped page number" at the bottom, I like the idea from David Carlisle's approach, but couldn't get it to work. (The \raisebox didn't seem to have an effect for me, seems the shifts are absorbed by the \vfill.) Here's what I defined to get that idea to work:

\def\fillandplacepagenumber{%
 \par\pagestyle{empty}%
 \vbox to 0pt{\vss}\vfill
 \vbox to 0pt{\baselineskip0pt
   \hbox to\linewidth{\hss}%
   \baselineskip\footskip
   \hbox to\linewidth{%
     \hfil\thepage\hfil}\vss}}

Using that definition, one can now place a "landscaped page number" as follows:

% Preamble needs: \usepackage{pdflscape}
\begin{landscape}
  Landscape content.
  \fillandplacepagenumber
\end{landscape}

For several landscape pages in a row, one can just repeat separate copies of the block shown above, or the following also works:

% Preamble needs: \usepackage{pdflscape}
\begin{landscape}
  Landscape content.
  \fillandplacepagenumber
\newpage
  More landscape content.
  \fillandplacepagenumber
\end{landscape}

Possibly an easy fix to David Carlisle's \raisebox approach exists and thus would be a simpler (and more LaTeX-like) solution than the messy \fillandplacepagenumber shown here.

4
  • I tried this solution and it works for putting the page number at the bottom, however now I have two page numbers: one on the side and one at the bottom...am I missing something? Feb 13 at 16:41
  • @LucaClissa, I tried it again, still seems to work. The standard footer places the page number on the left side of the landscape page. The \pagestyle{empty} at the start of \fillandplacepagenumber clears out that footer. Are you perhaps loading a competing header/footer package that doesn't respond to \pagestyle{empty}? Feb 15 at 0:33
  • @AlexanderPerils I don't think, at least not that I am aware of...I am using a standard overleaf article template, here you can find a minimal reproducible example (the figure is in page 2) Feb 15 at 10:39
  • @LucaClissa, in your linked example, move \fillandplacepagenumber outside the \caption (move it entirely outside the figure environment). May 25 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.