![\newpage を含む enumerate 環境内のすべての \item の後に \vfill を取得するにはどうすればよいですか?](https://rvso.com/image/472713/%5Cnewpage%20%E3%82%92%E5%90%AB%E3%82%80%20enumerate%20%E7%92%B0%E5%A2%83%E5%86%85%E3%81%AE%E3%81%99%E3%81%B9%E3%81%A6%E3%81%AE%20%5Citem%20%E3%81%AE%E5%BE%8C%E3%81%AB%20%5Cvfill%20%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF%E3%81%A9%E3%81%86%E3%81%99%E3%82%8C%E3%81%B0%E3%82%88%E3%81%84%E3%81%A7%E3%81%99%E3%81%8B%3F.png)
私は授業用のノートパックを作成しようとしています。これは基本的に1ページに2つか3つの質問が書かれた長いリストで、各質問の後に生徒が解答を導き出せるスペースがあります。私はそのenumitem
パッケージを使用していて、ほとんど完璧な解決策は、カスタム リスト環境を使用し、垂直方向の間隔の作業を定義するitemsep
ことです。after
\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}
これは問題なく動作しますが、手動で次のコードを挿入して、これらの質問を 2 ページに分散することにします\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
グルー (glue) がコマンドによって挿入されるため\item
、2 ページ目の先頭にあり、ルールによって破棄されてしまうことです。
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*.}