如何在包含 \newpage 的枚舉環境中的每個 \item 之後獲得 \vfill?

如何在包含 \newpage 的枚舉環境中的每個 \item 之後獲得 \vfill?

我正在嘗試為我的班級創建一個筆記包,它基本上是一長串問題,一頁有 2 或 3 個問題,每個問題後都有空間,學生可以在其中找到解決方案。我正在使用這個enumitem包,並且我已經制定了一個幾乎完美的解決方案,使用自訂清單環境並定義itemsepafter執行垂直間距工作:

\documentclass{article}
\usepackage[shortlabels]{enumitem}
\newlist{questions}{enumerate}{1} 
\setlist[questions]{label=\itshape{{Question }\arabic*.},
                    ref={Question }\arabic*,
                    leftmargin=*,
                    itemindent=*,
                    itemsep=\fill, 
                    after={\vfill},
                    resume}

\begin{document}
    \begin{questions}
        \item First Question
        \item Another Question
        \item Another Question
        \item Another Question
    \end{questions}
\end{document}

這工作得很好,直到我決定通過手動插入以下內容將這些問題分散到兩頁上\newpage

\begin{document}
    \begin{questions}
        \item First Question
        \item Another Question
           \newpage
        \item Another Question
        \item Another Question
    \end{questions}
\end{document}

在此版本中,問題 2 位於第 1 頁的底部,後面沒有空格。我可以透過questions在新頁面之前結束清單並在之後重新啟動它來修復它,如下所示:

\begin{document}
    \begin{questions}
        \item First Question
        \item Another Question
    \end{questions}
           \newpage
    \begin{questions}
        \item Another Question
        \item Another Question
    \end{questions}
\end{document}

……但是每次我想插入新頁面時結束並重新啟動列表是一件痛苦的事情。

是否有更“優雅”(閱讀:更簡單)的方法來使用 enumitem 包獲得我想要的行為?我非常喜歡 enumitem,除非有充分的理由,否則我寧願不切換到其他軟體包。

答案1

有一個自動\vfil\newpage.它被壓碎了\fill

\documentclass{article}
\usepackage[shortlabels]{enumitem}
\newlist{questions}{enumerate}{1} 
\setlist[questions]{label=\itshape{{Question }\arabic*.},
                    ref={Question }\arabic*,
                    leftmargin=*,
                    itemindent=*,
                    itemsep=0pt plus 1fil, 
                    resume}

\begin{document}
    \begin{questions}
        \item First Question
        \item Another Question
    \newpage
        \item Another Question
        \item Another Question
    \end{questions}
\end{document}

答案2

問題是\itemsep黏合是透過命令插入的\item,因此它位於第二頁的頂部,並根據規則被丟棄。

我認為沒有辦法“回溯”,因為當 TeX 完成一個頁面時,它會將其從記憶體中刪除。因此需要\vfill在前面手動添加\newpage

加入一些語義,你可以這樣做

\newcommand{\questionbreak}{\vfill\pagebreak}

例子:

\documentclass{article}
\usepackage{enumitem}

\newlist{questions}{enumerate}{1}
\setlist[questions]{
  label=\textit{Question} \arabic*.,
  ref=Question \arabic*,
  leftmargin=*,
  itemindent=*,
  itemsep=\fill,
  after=\vfill,
  resume,
}

\newcommand{\questionbreak}{\vfill\pagebreak}

\begin{document}

\begin{questions}
\item First Question

\item Another Question

\questionbreak

\item Another Question

\item Another Question

\end{questions}

\end{document}

在此輸入影像描述

檢查小的變化:\itshape不需要爭論。如果您希望數字也以斜體顯示,請執行以下操作

label=\textit{Question \arabic*.}

相關內容