我正在准备考试,我想在多项选择题旁边放一张插图。通常为了这个目的,我会把问题和/或选项放在一个multicols
环境中;但是对于这个特定的问题,页面宽度的一半一半分割使得multicols
每个选项的文本换行,而图像相当窄。
我以为我可以通过将选项放在中来获得我想要的东西minipage
,但是小页面改变了选项之间的间距:
\documentclass{article} %% 'exam' class not needed for MWE
\begin{document}
\begin{enumerate}
\item
This is a standard nested enumeration.
\begin{enumerate}
\item Spacing within wrapped text and between lines of the enumeration
looks okay to me.
\item adsflkj adsflkj
\item qeworui qeworui
\item zcx,vmn zcx,vmn
\item lkjasdf lkjasdf
\item mbnnert mbnnert
\end{enumerate}
\item
The possible answers to this question are in a minipage,
to accomodate an image to the right
\begin{minipage}[t]{0.6\linewidth}
\begin{enumerate}
\item Spacing within wrapped text is the same, but the spacing
between items is different.
\item adsflkj adsflkj
\item qeworui qeworui
\item zcx,vmn zcx,vmn
\item lkjasdf lkjasdf
\item mbnnert mbnnert
\end{enumerate}
\end{minipage}
\hfill
\fbox{Tikz image here}
\end{enumerate}
\end{document}
这种差异让我很烦恼。我该如何解决?
\addtolength{\itemsep}{-1ex}
(我可以通过小型页面来或多或少地破解它。但\the\itemsep
在各个地方显示\itemsep
实际上并不是被秘密改变的长度。我宁愿了解实际发生了什么。)
答案1
Aminipage
确实明确重置了列表深度,请latex.ltx
参见第 4886 行中的以下代码:
\let\@listdepth\@mplistdepth \@mplistdepth\z@
重要的是\@mplistdepth\z@
,这意味着零列表深度——内部enumerate
环境的行为就像再次处于第一级,使用\itemsep
值“适当”作为此级别,4.0pt plus 2.0pt minus 1.0pt
在这种情况下。(同样如此itemize
)。然后使用其他间距,就像在枚举/逐项环境的第一级一样,这就是缩进等的原因,(a)
如从 OP 中的图像中可以看到的那样。
有趣的是,枚举计数器格式没有重置,因为\@enumdepth
当时仍然具有值 2(即第二级)。
一个便宜的技巧就是手动\@mplistdepth
明确地将计数器设置为1
。
\documentclass{article} %% 'exam' class not needed for MWE
\usepackage{enumitem}
\begin{document}
\begin{enumerate}
\item This is a standard nested enumeration.
\begin{enumerate}
\item Spacing within wrapped text and between lines of the enumeration
looks okay to me.
\item adsflkj adsflkj
\item qeworui qeworui
\item zcx,vmn zcx,vmn
\item lkjasdf lkjasdf
\item mbnnert mbnnert
\end{enumerate}
\item The possible answers to this question are in a minipage,
to accomodate an image to the right
\begin{minipage}[t]{0.6\linewidth}
% minipage does this thing here: \let\@listdepth\@mplistdepth \@mplistdepth\z@
\makeatletter
\@mplistdepth=1
\makeatother
\begin{enumerate}
\item Spacing within wrapped text is the same, but the spacing
between items is different.
\item adsflkj adsflkj
\item qeworui qeworui
\item zcx,vmn zcx,vmn
\item lkjasdf lkjasdf
\item mbnnert mbnnert
\end{enumerate}
\end{minipage}
\hfill
\fbox{Tikz image here}
\end{enumerate}
\end{document}
一种“更好”的方法是修补@iiiminipage
(“环境”的最内层minipage
并使其意识到应该保留列表深度,这取决于条件:
说明\mpsavelistdepthtrue
是否应启用保存以及\mpsavelistdepthfalse
是否应禁用保存。
这仅适用于enumerate
环境,因为\@enumdepth
处理的是enumerate
,而不是itemize
(相关的深度计数器是\@itemdepth
)
\documentclass{article} %% 'exam' class not needed for MWE
\usepackage{enumitem}
\usepackage{xpatch}
\newif\ifmpsavelistdepth
\mpsavelistdepthtrue % Enabling the list depth save for enumerate environments
\makeatletter
\xpatchcmd{\@iiiminipage}{%
\let\@listdepth\@mplistdepth \@mplistdepth\z@
}{%
\let\@listdepth\@mplistdepth
\ifmpsavelistdepth
\@mplistdepth\@enumdepth % use the current depth (stored in \@enumdepth
\fi
}{\typeout{Patching minipage succeeded}}{\typeout{Patching failed}}% End of patching
\makeatother
\begin{document}
\begin{enumerate}
\item This is a standard nested enumeration.
\begin{enumerate}
\item Spacing within wrapped text and between lines of the enumeration
looks okay to me.
\item adsflkj adsflkj
\item qeworui qeworui
\item zcx,vmn zcx,vmn
\item lkjasdf lkjasdf
\item mbnnert mbnnert
\end{enumerate}
\item The possible answers to this question are in a minipage,
to accomodate an image to the right
\begin{minipage}[t]{0.6\linewidth}
\begin{enumerate}
\item Spacing within wrapped text is the same, but the spacing
between items is different.
\item adsflkj adsflkj
\item qeworui qeworui
\item zcx,vmn zcx,vmn
\item lkjasdf lkjasdf
\item mbnnert mbnnert
\end{enumerate}
\end{minipage}
\hfill
\fbox{Tikz image here}
\end{enumerate}
\end{document}