2

I use pdflscape to contain a table. After this page, the page number which should be at the bottom of that page is missing. How should I resume it? There is no page number at the bottom of the page.

\documentclass{article}
\usepackage{lipsum,tabularray,afterpage,geometry,pdflscape}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\fancyhf{}
\cfoot{\thepage}
\pagestyle{fancy}
\begin{document}
\section{New section}
\lipsum{1-6}
\afterpage{\newgeometry{left=2cm,right=2cm,bottom=0.5cm,top=0.5cm}
    \begin{landscape}
    \pagestyle{empty}
        \begin{longtblr}{
                colspec={X[l,3em] X[c,4em] X[c,4em] X[c,3.5em] X[c,3em] X[c,3em] X[c,4em] X[c,2em] X[c,3em] X[c,3em] X[c,4em] X[c,4em] X[c,4em] X[c,3.5em] X[c,4em] X[c,3em] X[c,6em] X[c,3.2em]},colsep=1pt,rowhead=1
            }
          %  \newgeometry{left=2cm,right=2cm,bottom=0.5cm,top=0.5cm}
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        \end{longtblr}
    \end{landscape} \restoregeometry\clearpage
    }
\lipsum{7-12}\lipsum{7-12}

\end{document}

enter image description here

Y. zeng
  • 1,885

1 Answers1

3

It should be square brackets for \lipsum[1]. And this is how to achieve that:

Edit: To answer your question in the comment:

\aftergroup to make you \restoregeometry right after the current group. Because sometime macros or package commands may contain multiple groups in the definition. So you may not properly reset the geometry for after page.

The lipsum package document have the definition for \lipsum marco. You can check it out (on page.3). So \lipsum only take 2 optional args, first one is the par range and second one is the sentence range. Latex treat stuff in [ ] as a optional arg. So if you do \lipsum{1-5}, it will treat the {1-5} as the following contents that you want to type out and use \lipsum default par range, which will be 1-7, to execute command \lipsum to output . So \lipsum and \lipsum{1-20} will basically output the same thing, except you will see 1-20 right after the dummy text. Latex don't issue errors when you do this. So sometimes you need to check documentation of package in order to properly use a command.

\documentclass{article}
\usepackage{lipsum,tabularray,afterpage,geometry,pdflscape}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\fancyhf{}
\cfoot{\thepage}
\pagestyle{fancy}
\begin{document}
\section{New section}
\lipsum[1-6]
\afterpage{\newgeometry{left=2cm,right=2cm,bottom=0.5cm,top=0.5cm}
    \begin{landscape}
        \begin{longtblr}{
                colspec={X[l,3em] X[c,4em] X[c,4em] X[c,3.5em] X[c,3em] X[c,3em] X[c,4em] X[c,2em] X[c,3em] X[c,3em] X[c,4em] X[c,4em] X[c,4em] X[c,3.5em] X[c,4em] X[c,3em] X[c,6em] X[c,3.2em]},colsep=1pt,rowhead=1
            }
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18\\
        \end{longtblr}
    \end{landscape}\aftergroup\restoregeometry\clearpage
    }
\lipsum[7-16]

\end{document}

Tom
  • 7,318
  • 4
  • 21
  • Tom, please view https://tex.stackexchange.com/questions/646431/how-to-center-a-table-wider-than-textwidth-in-pdflscape-in-latex/, in which the author of the question indicated that they wish to avoid having the vertical space on the 2nd page. However, the given code in your answer makes this space persist. Thank you for your consideration! – Miriam Briskman Jun 02 '22 at 05:16
  • Why after you added \aftergroup, the page number was shown? – Y. zeng Jun 02 '22 at 06:07
  • Before, I used \lipsum[1-5], but somebody told me to use \lipsum{1-5}, so what's the difference between { [ in lipsum? – Y. zeng Jun 02 '22 at 06:09
  • 1
    @MiriamBriskman His modified answer resolved the vertical space. Thanks a lot! – Y. zeng Jun 02 '22 at 06:09
  • @Y. It is too long to response you in the comment. So I add it to the answer – Tom Jun 02 '22 at 06:41
  • @Tom, your edition to the answer indeed resolves all the aforementioned issues, so my 1st comment is obsolete now. Thank you very much again! – Miriam Briskman Jun 02 '22 at 06:55
  • @Miriam You are welcome. Thank you for mention it to me, cause OP didn't include that in the question. And I don't have idea which relate to another post. – Tom Jun 02 '22 at 06:58
  • Thank you, @Tom! – Miriam Briskman Jun 02 '22 at 08:02
  • @Tom Thanks for your added answers. Have a nice day ahead. – Y. zeng Jun 02 '22 at 08:02
  • @Tom I found there is no need to add \clearpage here, as I deleted it, all things are right. – Y. zeng Jun 02 '22 at 10:07