1

I knew how to resume the page number after the pdflscape at the footer if the content is the text as in the case.

But if the following content after the pdflscape are equations, the next page number will not be shown. As:

\documentclass{article}
\usepackage{lipsum,tabularray,afterpage,geometry,pdflscape,amsmath}
\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
    }
    \begin{equation}
    \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}}
\end{equation}
\begin{equation}
    \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}}
\end{equation}
\begin{equation}
    \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}}
\end{equation}
\begin{equation}
    \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}}
\end{equation}
 \begin{equation}
    \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}}
\end{equation}
\begin{equation}
    \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}}
\end{equation}
\begin{equation}
    \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}}
\end{equation}
\begin{equation}
    \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}}
\end{equation}
 \begin{equation}
    \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}}
\end{equation}
\begin{equation}
    \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}}
\end{equation}
\begin{equation}
    \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}}
\end{equation}
\begin{equation}
    \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}}
\end{equation}
\lipsum[1-16]

\end{document}

No page number after pdflscape

Y. zeng
  • 1,885
  • are you sure you want to use \aftergroup from inside \aferpage???, the effect of that is well defined but very weird and hard to define. Almost the entire afterpage package code is concerned with juggling \aftergroup – David Carlisle Jun 08 '22 at 07:15
  • @DavidCarlisle If I delete the \aftergroup, the next page number after the table will not be shown. I don't know the reason and another person told me this would resolve this problem. – Y. zeng Jun 08 '22 at 08:18
  • It is my code and I promise you using aferpage at all is slightly risky, using\aftergroup from \afterpage is taking you in to uncharted and untested waters and any behaviour that does or does not happen is the result of unexpected consequeces and not really fixable or maintainable. There is nothing here that I can see to make the page number go from any page, so if it does go, fix that first not add extra broken code to try to bring it back. – David Carlisle Jun 08 '22 at 08:47
  • @DavidCarlisle Replace \end{landscape}\aftergroup\restoregeometry\clearpage with \end{landscape}\restoregeometry\clearpage and you will see no page number on the page after the table page. If not use \aftergroup, how should we bring the page number of the next page after the table back? – Y. zeng Jun 08 '22 at 08:52
  • your real issue is incorrect geometry setting, for testing change your \cfoot line to \usepackage[T1]{fontenc}\usepackage{lmodern}\cfoot{\smash{\fontsize{3in}{3in}\selectfont\thepage}} so that you see (parts of) the page number even when you are placing the page foot off the page. As I said above, you should fix the bug that the page numbers are not shown in the landscape pages first, – David Carlisle Jun 08 '22 at 08:58
  • @DavidCarlisle I don't know how to fix it. Do you have an idea? – Y. zeng Jun 08 '22 at 09:21
  • Out of topic: \cfoot{} is a deprecated macro and \fancyfoot[]{} is recommended instead (see p. 45 of fancyhdr - Users' manual) – Celdor Jun 08 '22 at 10:31

1 Answers1

1

I think the reason is the pagebreak happened right at the first equation start. what you can do is adding a empty line between the afterpage contents and first equation. And move the \aftergroup\restoregeometry\clearpage inside the landscape env right after the \end{longtblr}

\documentclass{article}
\usepackage{lipsum,tabularray,afterpage,geometry,pdflscape,amsmath}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\fancyhf{}
\cfoot{\thepage}
\pagestyle{fancy}
\begin{document}
\section{New section}
\lipsum[1-7]
\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}\aftergroup\restoregeometry\clearpage
    \end{landscape}
    }

\begin{equation} \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}} \end{equation} \begin{equation} \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}} \end{equation} \begin{equation} \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}} \end{equation} \begin{equation} \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}} \end{equation} \begin{equation} \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}} \end{equation} \begin{equation} \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}} \end{equation} \begin{equation} \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}} \end{equation} \begin{equation} \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}} \end{equation} \begin{equation} \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}} \end{equation} \begin{equation} \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}} \end{equation} \begin{equation} \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}} \end{equation} \begin{equation} \mathrm{NPI}=\sqrt{\dfrac{{\left[\dfrac{1}{n}\sum\limits_{i=1}^n \dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right]}^2+{\left[\mathrm{Max}{\left(\dfrac{\mathrm{C_i}}{\mathrm{S_i}}\right)}\right]}^2}{2}} \end{equation} \lipsum[1-16]

\end{document}

enter image description here

Tom
  • 7,318
  • 4
  • 21
  • Hello, Thanks for your reply. I tested your code and found there is no need to add an empty line before the first equation. The \newgeometry was added before \begin{landscape}, but \aftergroup\restoregeometry\clearpage was added before \end{landscape}, what's the reason? – Y. zeng Jun 08 '22 at 03:58
  • @Y. I don't know the exactly reason. What I am thinking is the \restoregeometry at the end of landscape was too late that the page break was already heppened. So the following page was not show the number. Maybe someone else can explain it better. – Tom Jun 08 '22 at 04:46
  • @Y.zeng placing before end landscape is the same as leaving it after end {landscape} but deleting \aftergroup. Either way, you do not \aftergroup out of \afterpage which is the real source of the problem, – David Carlisle Jun 08 '22 at 07:19
  • @DavidCarlisle I see these codes \end{landscape}\restoregeometry\clearpage will make the next page number after the table not shown. – Y. zeng Jun 08 '22 at 08:21