页面旋转时放置页码,并附加警告

页面旋转时放置页码,并附加警告

考虑以下 MWE:

\documentclass{article}

\usepackage{pdflscape}
\usepackage{everypage}

\newcommand*\Lpagenumber{\ifdim\textwidth=\textwidth\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\textwidth}[0pt][0pt]{%
    \rlap{\hspace{\dimexpr \margin+\textheight+\footskip}%
    \llap{\rotatebox{90}{\thepage}}}}%
\egroup\fi}
\AddEverypageHook{\Lpagenumber}%

\begin{document}

\begin{landscape}
Test
\end{landscape}

\end{document}

问题 1

当我去年编译此代码(或等效代码)时,我认为,页码被很好地放置在旋转页面的底部;现在它被旋转到页面的左侧,就好像页面旋转时数字保持不变。

我该如何解决这个问题,以便让数字位于页面的底部中央?(lualatex如果这很重要,我会使用它来编译。)

问题2

我也收到警告

Package everypage Warning: Functionality similar to this package has recently
(everypage)                been implemented in LaTeX. This package is now in
(everypage)                legacy status.
(everypage)                Please, don't use it in new documents and packages.


Package everypage Warning: You appear to be running a version of LaTeX
(everypage)                providing the new functionality.
(everypage)                Doing the best to deliver the original `everypage`
(everypage)                interface on top of it. Strict equivalence is
(everypage)                not possible, breakage may occur.
(everypage)                If truly needed, Use `everypage-1x` to force the
(everypage)                loading of an older code base.

我可以以某种方式更改代码以避免出现此警告吗?

更新

我认为可以使用下面的方法来解决警告问题(我发现这里):

\documentclass{article}

\usepackage{pdflscape}

\AddToHook{shipout/background}{
\ifdim\textwidth=\textwidth\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\textwidth}[0pt][0pt]{%
    \rlap{\hspace{\dimexpr \margin+\textheight+\footskip}%
    \llap{\rotatebox{90}{\thepage}}}}%
\egroup\fi
}%

\begin{document}

\begin{landscape}
Test
\end{landscape}

\end{document}

PS:我仍然不知道如何解决问题1。

答案1

您可以做类似的事情。但您需要计算旋转后的页码应该位于何处。

\documentclass{article}

\usepackage{pdflscape,lipsum}

\AddToHook{env/landscape/begin}
 {%
  \clearpage
  \pagestyle{empty}
  \AddToHook{shipout/background}[sven/page]
    {
     \put(0.9\paperwidth,-0.5\paperheight)%adapt values
      {\rotatebox{90}{\thepage}}
    }%
 }     

\AddToHook{env/landscape/after}
 {\RemoveFromHook{shipout/background}[sven/page]}


\begin{document}


\lipsum 

\begin{landscape}
\lipsum 
\end{landscape}

\lipsum 
\end{document}

相关内容