我有一份 scrreprt 文档,其中中间的两页是横向的,并包含一个长表。我使用 pdflatex 以防万一。
我的代码本质上是:
\documentclass{scrreprt}
\begin{document}
...
\newpage
\storeareas\myvalues
\KOMAoptions{pagesize, paper=landscape, DIV=20}
\newpage
\begin{longtable}{l}
...
\end{longtable}
\clearpage
\myvalues
\newpage
...
\end{document}
除页码外,一切都很好。
在两张横向页面上,我将页码放在页面长边的底部,但我希望将它们放在与纵向页面基本相同的位置,即页面长边的底部。
我如何实现这个目标?
玩了一会儿后,我发现这不是由于长表造成的,而是出现在任何横向页面中。一个最小工作示例可以说明这一点:
\documentclass{scrreprt}
\begin{document}
\newpage
\storeareas\myvalues
Page numbers are fine here.
\KOMAoptions{pagesize, paper=landscape, DIV=20}
Page numbers are not fine on this page. They should be 90 degrees rotated and centered on the shorter edge of the paper just as on page 1 and 3.
\clearpage
\myvalues
\newpage
\KOMAoptions{pagesize, paper=portrait, DIV=20}
Page numbers are fine here.
\end{document}
但问题仍然存在:如何将页码放置在与纵向页面相同的位置?
答案1
我认为这\KOMAoptions[paper=landscape]
不仅可以设置页面内容,还可以设置横向模式下的页眉和页脚。我自己的设置(仅是必要的)---用于 4 页长表,主要是文本---,用于像纵向模式一样保留页码和页眉:
\afterpage{% \RequirePackage{afterpage} %causes the commands specified in its argument to be expanded after the current page is output
\clearpage% Flush earlier floats (otherwise order might not be correct)
\pdfbookmark[2]{Title for pdf bookmarks}{sec:D1}
\tolerance=1 % no hyphenation
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000
\begin{landscape}% Landscape page \RequirePackage{pdflscape} %PDF support to the environment landscape
\footnotesize
\legend{\Large Caption of the table} \label{D1}
\vspace{-15pt}
\begin{center}
\begin{longtable}{m{200pt}m{3pt}m{20pt}m{240pt}}
\toprule
.... & ... &... & ...\\ %column titles
\endfirsthead
\multicolumn{4}{r} {\footnotesize \emph{ \ldots{} from previous page.}} \\
\toprule
.... & ... &... & ...\\ %column titles
\midrule
\endhead
\multicolumn{4}{r}{\footnotesize \emph{Continued on the next page \ldots{} }} \\
\endfoot
% \bottomrule
\endlastfoot
\midrule
.... & ... & .... & ... \\
.... & ... & .... & ... \\
.... & ... & .... & ... \\
.... & ... & .... & ... \\
etc
\bottomrule
\end{longtable}%
\end{center}
\end{landscape}%
\clearpage
}
请参阅《KOMA-Script 指南》(2020 年)第 417 页第 16 章。请提供 MWE 以查看并尝试您的完整配置。
更新
\documentclass{scrreprt}
\RequirePackage{pdflscape}
\begin{document}
\newpage
\storeareas\myvalues
Page numbers are fine here.
%\KOMAoptions{pagesize, paper=landscape, DIV=20}
\begin{landscape}
Page numbers now are FINE on this page. They should be 90 degrees rotated and centered on the shorter edge of the paper just as on page 1 and 3.
\end{landscape}
\clearpage
%\myvalues
%\newpage
\KOMAoptions{pagesize, paper=portrait, DIV=20}
Page numbers are fine here.
\end{document}
现在,页码 2 与页码 1 和页码 2 位于同一位置。这对于屏幕阅读来说没问题
如果需要打印文档,也许旋转的替代方案更好。
\documentclass{scrreprt}
\RequirePackage{pdflscape}
\usepackage{rotating}
\begin{document}
\newpage
\storeareas\myvalues
Page numbers are fine here.
%\KOMAoptions{pagesize, paper=landscape, DIV=20}
\begin{sidewaysfigure}
Page numbers now are FINE on this page. They are 90 degrees rotated and centered on the shorter edge of the paper just as
\end{sidewaysfigure}
\clearpage
%\myvalues
%\newpage
\KOMAoptions{pagesize, paper=portrait, DIV=20}
Page numbers are fine here.
\end{document}