0

I have a similar question to this one asked a few years ago: single landscape page with page number at the bottom?

Unfortunately the solution shown in that question doesn't seem to work any longer due to the package everypage.sty no longer existing (see So what is the everypage package replacement? and https://ctan.org/tex-archive/macros/latex/contrib/everypage)?

I have a wide (at least 12 columns) and very long (upwards of 200 rows) longtable which takes up multiple pages. I would like to display it in landscape instead of portrait.

I tried implementing the solution suggested by user John Kormylo in the above Stack question but Latex is throwing up an error that "File 'everypage.sty' not found" which makes sense if that package has been replaced somehow.

\usepackage{pdflscape}
\usepackage{longtable}
\usepackage{everypage}

%%%%the below stuff is to attempt to keep page numbers on the bottom of the page even in landscape mode.
%%%%It came from here, and all credit goes to user John Kormylo: %%%%https://tex.stackexchange.com/questions/278113/single-landscape-page-with-page-number-at-the-bottom \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} \begin{longtable}{|c|c|c|c|c|c|c|c|c|c|c|c|} %headers and stuff go here, not relevant to my issue

\hline StarID&$q_{EM,red}$&$q_{EM,blue}$&$q_{LAD,red}$&$q_{LAD,blue}$&StarType&$ EM_{Time}$&$LAD_{Time}$&BPred&BPblue&Cred&Cblue\ \hline 10.4285&1&1&1&0&cepheid&52.079&10.998&Incorr&Incorr&Incorr&Corr \ \hline 10.4396&1&1&1&1&cepheid&50.38&13.313&Incorr&Incorr&Incorr&Incorr \ \hline %%%lots more lines in an identical style

\end{longtable} \end{landscape}

\end{document}

A few notes:

-My documentclass is some specially created thesis thing made by my university (but based off of the book class) and I don't think I can share it so I wasn't sure what documentclass to use above

-My university will not allow me to mess with 1 inch margins on all sides

-I'm not stuck on using the pdflscape package, I just appreciate how readers can see the rotated page cleanly while reading the document on a screen

Char19
  • 15
  • Actually, I believe fancyhdr can handle landscape now. Also, if this is going to be printed (library copy) then the header and footer should remain where they are. – John Kormylo Feb 16 '24 at 15:19
  • @JohnKormylo thanks for pointing that out. Currently my university only accepts digital copies of theses, and they can only be accessed as digital pdfs. However I can get a printed copy for myself and certainly then I'll need to make a few changes. – Char19 Feb 16 '24 at 17:42
  • @JohnKormylo I'm not familiar with fancyhdr so i'm just learning it right now, all the examples I've seen define the page style at the point in their document when they want a fancy page, but is this compatible with longtable? I don't know until after I execute my file how many pages my table will occupy... – Char19 Feb 16 '24 at 18:07
  • The header and footer are added during the shipout process, which does not involve longtable. You can predefine the pagestyle, then activate it with \pagestyle{fancy}. Note that there is only one fancy page style at a time. – John Kormylo Feb 16 '24 at 20:20
  • @JohnKormylo thanks for the clarification, that makes total sense! – Char19 Feb 16 '24 at 22:27

1 Answers1

1

I wasn't sure what effect pgflscape would have on \put.

\documentclass{book}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}% for \rotetebox

\newcommand{\Lpagenumber}{\ifdim\textwidth=\linewidth\else\bgroup \dimendef\margin=0 %use \margin instead of \dimen0 \ifodd\value{page}\margin=\oddsidemargin \else\margin=\evensidemargin \fi \put (\dimexpr 1in+\margin+\textheight+\footskip\relax, \dimexpr -1in-\topmargin-\headheight-\headsep-\linewidth\relax) {\rotatebox[origin=lb]{90}{\makebox[\linewidth]{\thepage}}}% \egroup\fi} \AddToHook{shipout/background}{\Lpagenumber}

\begin{document}

\begin{landscape} \pagestyle{empty}% \begin{longtable}{|c|c|c|c|c|c|c|c|c|c|c|c|} %headers and stuff go here, not relevant to my issue

\hline StarID&$q_{EM,red}$&$q_{EM,blue}$&$q_{LAD,red}$&$q_{LAD,blue}$&StarType&$ EM_{Time}$&$LAD_{Time}$&BPred&BPblue&Cred&Cblue\ \hline 10.4285&1&1&1&0&cepheid&52.079&10.998&Incorr&Incorr&Incorr&Corr \ \hline 10.4396&1&1&1&1&cepheid&50.38&13.313&Incorr&Incorr&Incorr&Incorr \ \hline %%%lots more lines in an identical style

\end{longtable} \end{landscape}

\end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • thanks for your help! Unfortunately this solution is giving me a "Undefined control sequence \AddToHook" error. The only difference I can see between your solution and my template is that the template seems to load the geometry package without specifying a margin, and then defining the margin in a separate call to geometry, defining hmargin and vmargin as {1in,1in} for both. I do have all the mentioned packages loaded. – Char19 Feb 16 '24 at 18:00
  • \AddToHook is now a part of standard LaTeX. You should update your packages, or re-install your LaTeX compiler. – John Kormylo Feb 16 '24 at 20:15