3

I am working with a document that has several pages that are in landscape mode. I do realize there are different ways of managing the document - for example, using sideways table with the rotating package - but I do want landscape mode with the pdflscape package. In landscape mode, the page in PDF will actually change orientation - which will make it easier for the vast majority of readers to read as the text will be oriented the right way for the reader (and likely the vast majority of readers of the document as few will print it out). The issue I have is that the page numbers are flipped - the page numbers appear at the top of the document when printed and not at the bottom. It is not easy to see this in the document itself; however, when printed the page numbers are oriented improperly as they are placed at the top of the page and not the bottom. The page numbers should appear toward the 2/4 side of the landscape page, not the 1/3 side. Is there someway to solve this issue? I would much prefer to set the page with landscape to make it easier to read for those reading online.

%% LyX 2.0.7 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{pdflscape}
\usepackage{rotating}

\makeatother

\usepackage{babel}
\begin{document}
Test 1 2 3.

\pagebreak{}

\begin{landscape}%
\begin{tabular}{|c|c|}
\hline 
1 & 2\tabularnewline
\hline 
\hline 
3 & 4\tabularnewline
\hline 
\end{tabular}\end{landscape}

\pagebreak{}

\begin{sidewaystable}%
\begin{tabular}{|c|c|}
\hline 
1 & 2\tabularnewline
\hline 
\hline 
3 & 4\tabularnewline
\hline 
\end{tabular}\end{sidewaystable}
\end{document}
user65240
  • 107
  • 1
    (pdf)lscape leaves the page numbers where they are and rotates the body 90 degrees anti(counter)-clockwise: is your printer driver applying further rotations to the pdf on printing? the page number 2 does appear (at the bottom of the page) at the 1/3 edge of the table – David Carlisle Oct 30 '14 at 01:11
  • I can't say for certain. What I can say is that the pdf output that is generated, as printed, is incorrect. This happens for both even numbered and odd numbered pages. Certainly if the entire page was 180 degrees it would be fine - but I'm just sending the document to a printer and it is printed in duplex and, as is, is upside down. – user65240 Oct 30 '14 at 01:18
  • http://tex.stackexchange.com/questions/60273/page-numbers-in-landscape?rq=1 may help. There is a hack in the comments to the answer which apparently works for standard classes. – cfr Oct 30 '14 at 01:18
  • Thanks, yes, I saw that hack and it did not work for me. I seem to recall I received an error. Some people want the page number to change orientation with the content, I specifically want all page numbers at the bottom of the page in the same orientation. – user65240 Oct 30 '14 at 01:21
  • 1
    I suspect that your printer software is trying to be smart and auto-rotate stuff (not unknown) (you could try lscape rather then pdflscape) which will omit the instructions to rotate the view for online reading, neither pdflscape or lscape change the orientation of the page or move the page numbers, they only rotate the inner part of the page between head and foot, but your printer may be confused by the rotated view set up – David Carlisle Oct 30 '14 at 01:23
  • OK, so it is certainly a reasonable suggestion. How could I test this out? I have the box on the page with 1 2 3 4 - are the page numbers in the "right" location for printing? It's hard to know for certain, but when I print out the document at a printer I know I want the numbers on the 2/4 side as printed in the lscape mode (or have the whole page rotated 180 degrees). – user65240 Oct 30 '14 at 01:32
  • as I say, pdflscape does not move the page numbers and rotates the page content anti-clockwise leaving the 1/3 side of the table at the bottom near the page number, if your printer driver is printing that page upside down then you need to look to the configuration there, not to latex, I think. – David Carlisle Oct 30 '14 at 01:55
  • OK, well the text is rotated as noted, counter-clockwise and thus does not appear to be a problem to be fixed within LaTeX. – user65240 Oct 30 '14 at 03:28
  • This answer (https://tex.stackexchange.com/a/278169) helped me. The solution uses the landscape environment. – rdrg109 Oct 17 '21 at 23:41

1 Answers1

3

Tikzpagenodes got confused by pdflandscape, so I had to do it the hard way.

\documentclass{article}
\usepackage{pdflscape}
\usepackage{tikz}

\begin{document}
Test 1 2 3.

\pagebreak{}

\begin{landscape}%
\thispagestyle{empty}
\begin{tikzpicture}[overlay]
\node[above] at (.5\linewidth,-\textwidth-\footskip) {\thepage};
\end{tikzpicture}

\begin{tabular}{|c|c|}
\hline 
1 & 2\\
\hline 
\hline 
3 & 4\\
\hline 
\end{tabular}
\end{landscape}

\end{document}

Here is an even more general solution using everypage:

\documentclass[english]{article}
\usepackage{pdflscape}
\usepackage{graphicx}
\usepackage{everypage}
\usepackage{lipsum}

\newlength{\hfoot}
\newlength{\vfoot}
\AddEverypageHook{\ifdim\textwidth=\linewidth\relax
\else\setlength{\hfoot}{-\topmargin}%
\addtolength{\hfoot}{-\headheight}%
\addtolength{\hfoot}{-\headsep}%
\addtolength{\hfoot}{-.5\linewidth}%
\ifodd\value{page}\setlength{\vfoot}{\oddsidemargin}%
\else\setlength{\vfoot}{\evensidemargin}\fi%
\addtolength{\vfoot}{\textheight}%
\addtolength{\vfoot}{\footskip}%
\raisebox{\hfoot}[0pt][0pt]{\rlap{\hspace{\vfoot}\rotatebox[origin=cB]{90}{\thepage}}}\fi}

\begin{document}
\noindent Test 1 2 3.

\pagebreak{}

\begin{landscape}%
\pagestyle{empty}
\lipsum[1-8]
\end{landscape}
\pagestyle{plain}

\end{document}

As far as I can tell, pdflscape uses the same margins only rotated 90^\circ. The top margin is actually the left margin, the right margin is actually the top margin, and so on.

John Kormylo
  • 79,712
  • 3
  • 50
  • 120