LaTeX中landscape环境导致页面缩小的问题如何解决?
修复exam文档类中pdflscape导致后续页面尺寸异常的问题
这个问题出在exam文档类和pdflscape包的兼容性上——pdflscape的landscape环境切换回纵向时,没有正确恢复exam类自定义的页面布局参数,导致后续页面的尺寸、边距和页码位置全部跑偏。
下面给两种可行的修复方法:
方法一:改用lscape包替代pdflscape
lscape包对自定义页面布局的文档类兼容性更好,替换后无需额外调整:
修改代码中包的引入部分,把\usepackage{pdflscape}换成\usepackage{lscape},完整代码如下:
\documentclass{exam} \usepackage{lscape} % 替换pdflscape \usepackage{pdfpages} \usepackage{lipsum} \printanswers \begin{document} Page1 \newpage Page2 \begin{landscape} \begin{solution} \includegraphics{example-image-a} \end{solution} \end{landscape} \lipsum \end{document}
编译后,landscape环境后的页面会自动恢复exam类的原始布局,页码位置也会回到正常的90%左右位置。
方法二:手动恢复exam类的页面设置(保留pdflscape)
如果必须使用pdflscape,可以在landscape环境结束后手动重置页面样式和参数:
在\end{landscape}之后添加重置命令,强制恢复exam类的原始页面布局:
\documentclass{exam} \usepackage{pdflscape} \usepackage{pdfpages} \usepackage{lipsum} \printanswers \begin{document} Page1 \newpage Page2 \begin{landscape} \begin{solution} \includegraphics{example-image-a} \end{solution} \end{landscape} % 手动恢复exam类的页面设置 \makeatletter \@resetperpage % 调用exam内部的页面重置命令 \makeatother \pagestyle{headandfoot} % 恢复默认页码样式 \lipsum \end{document}
这段代码会修正后续页面的尺寸和页码位置异常问题。
内容的提问来源于stack exchange,提问作者Sir Falk
相关产品推荐
相关产品推荐

