使用考试文档类和 pdflscape 包时,我遇到了边距问题。当我在考试文档中间插入一个横向页面时,它会大大加宽所有后续纵向页面的底部边距和后续横向页面的左边距。
最小工作示例(已更新):
\documentclass{exam}
\usepackage{pdflscape}
\usepackage{geometry}
\headrule
\footrule
\begin{document}
\begin{questions}
\question This is the first page.
\newpage
\question This is a second normal page.
\begin{landscape}
\question This is in landscape. The left margin is much wider.
\end{landscape}
\newgeometry{margin=3cm}
\question This is in portrait. The margins are fixed using newgeometry.
\begin{landscape}
\newgeometry{margin=3cm}
\question This is another page in landscape. The left margin is still affected.
\end{landscape}
\question This is another page in portrait. The margins are normal.
\end{questions}
\end{document}
有什么建议或者替代方案吗?
编辑:此\newgeometry[margin=length]
修复在和相关环境之外有效questions
,但在环境内部无效questions
。我已更新我的 MWE 以反映这一点。
答案1
编辑
如果你不打算使用 -package exam
,我找到了一个替代方案 –exsheets
:
\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage{exsheets}
\usepackage{lipsum}
\SetupExSheets[question]{type=exam}
\usepackage{pdflscape}
\begin{document}
\section{Your favorite subject, ever!}
\begin{question}{10}
This is our very first very difficult to solve question!
\end{question}
\begin{question}{4}
Explain your decision for the answer above.
\blank[width=5\linewidth,linespread=1.5]{}
\end{question}
\begin{landscape}
\section{Your least favorite subject, yes, you'll have to answer these questions, too!}
\begin{question}{1}
What is my favorite toy?
\end{question}
\begin{question}{2}
And what my favorit animal?
\end{question}
\lipsum[3]
\end{landscape}
\end{document}
看起来效果不错:
以前尝试解决此问题
大卫卡莱尔是对的,之后边距不会重置\end{landscape}
。
你可以使用几何来解决这个问题:
\documentclass{exam}
\usepackage{pdflscape}
\usepackage[margin=3cm]{geometry}
\headrule
\footrule
\begin{document}
This is the first page.
\newpage
This is a second normal page.
\begin{landscape}
This is in landscape. The margins are not affected.
\end{landscape}
\newgeometry{margin=3cm}
This is in portrait. The bottom margin is much wider.
\begin{landscape}
This is another page in landscape. Now the left margin is affected.
\end{landscape}
\newgeometry{margin=3cm}
This is another page in portrait. The margins are still affected.
\end{document}
答案2
如果你觉得原来的问题很奇怪,那就试试这个版本。
顺便说一句,我之前发现 pdflscape 不会改变\paperwidth
和\paperheight
,因此\newgeometry
无法正确计算\textwidth
和\textheight
。请参阅这里
\documentclass{exam}
\usepackage{pdflscape}
\usepackage{geometry}
\headrule
\footrule
\begin{document}
\begin{questions}
\question This is the first page.
\newpage
\fullwidth{height=\the\textheight, width=\the\linewidth, or \the\textwidth}
\question This is a second normal page.
\begin{landscape}
\fullwidth{height=\the\textheight, width=\the\linewidth, or \the\textwidth}
\question This is in landscape. The left margin is much wider.
\end{landscape}
\newgeometry{margin=3cm}
\question This is in portrait. The margins are fixed using newgeometry.
\begin{landscape}
\newgeometry{margin=3cm}
\fullwidth{height=\the\textheight, width=\the\linewidth, or \the\textwidth}
\question This is another page in landscape. The left margin is still affected.
\end{landscape}
\question This is another page in portrait. The margins are normal.
\end{questions}
\end{document}