我需要创建一个结构复杂的考试(使用部分、子部分,有时甚至使用子子部分)。同时,我只有有限的页数可用,因此需要将图形放在文本旁边以减少空白。
效果很好的方法是使用 paracol 将单个项目(部分、子部分或子子部分)放在图形旁边。但有时单个项目的垂直空间比图形小得多。所以我需要将多个项目(可能属于不同类型的项目)放在一列中,将图形放在另一列中。
我认为,我已经找到了一种方法来暂停 paracol 环境末尾的任何类型的列表,然后按照以下说明使用正确的编号恢复它如何恢复考试文件类别中的部分编号?
但现在我的问题是,左列中的文本实际上并没有停留在左列中,而是溢出到右列并与那里的图形重叠。只有 paracol 环境中的第一个项目实际上遵循列宽。这是一个示例(不是最小的,但演示了嵌套项目结构的类型,问题已经发生在第一个子部分中):
\documentclass[a4paper,
draft,
12pt]{exam}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[pangram]{blindtext}
\usepackage{graphicx}
\usepackage{paracol}
\pointformat{/\thepoints}
\addpoints
\pointsdroppedatright
%%%Exercises numbering%%%
%%% https://tex.stackexchange.com/questions/682327/exam-class-define-questionlabel-and-partlabel-conditionally/682446#682446 %%%
\makeatletter
\renewcommand{\thequestion}{\arabic{question}\@ifundefined{r@part@\arabic{question}@1}{\phantom{.0}}{.0}}
\renewcommand{\thepartno}{\arabic{question}.\arabic{partno}\@ifundefined{r@subpart@\arabic{question}@\arabic{partno}@1}{\phantom{.0}}{.0}}
\renewcommand{\thesubpart}{\arabic{question}.\arabic{partno}.\arabic{subpart}\@ifundefined{r@subsubpart@\arabic{question}@\arabic{partno}@\arabic{subpart}@1}{\phantom{.0}}{.0}}
\renewcommand{\thesubsubpart}{\arabic{question}.\arabic{partno}.\arabic{subpart}.\arabic{subsubpart}}
\renewcommand{\questionlabel}{\thequestion\hfill}
\renewcommand{\partlabel}{\hbox to \labelwidth{\thepartno\hfill}}
\renewcommand{\subpartlabel}{\hbox to \labelwidth{\thesubpart\hfill}}
\renewcommand{\subsubpartlabel}{\hbox to \labelwidth{\thesubsubpart\hfill}}
\renewcommand{\questionshook}{
\setlength{\leftmargin}{3em}
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\setlength{\linewidth}{\textwidth}
}
\renewcommand{\partshook}{
\setlength{\@totalleftmargin}{0pt}
\setlength{\leftmargin}{3em}
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\setlength{\linewidth}{\textwidth}
}
\renewcommand{\subpartshook}{
\setlength{\@totalleftmargin}{0pt}
\setlength{\leftmargin}{3em}
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\setlength{\linewidth}{\textwidth}
}
\renewcommand{\subsubpartshook}{
\setlength{\@totalleftmargin}{0pt}
\setlength{\leftmargin}{3em}
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\setlength{\linewidth}{\textwidth}
}
\makeatother
\newcounter{partscounter}
\newcounter{subpartscounter}
\newcounter{subsubpartscounter}
\begin{document}
\begin{questions}
\columnratio{0.6,0.4}
\begin{paracol}{2}
\begin{leftcolumn}
\question \Blindtext[1][3]
\begin{parts}
\part \Blindtext[1][3]
\begin{subparts}
\subpart[1] \Blindtext[1][3]
\droppoints
\subpart[1] \Blindtext[1][3]
\setcounter{subpartscounter}{\value{subpart}}
\end{subparts}
\setcounter{partscounter}{\value{partno}}
\end{parts}
\end{leftcolumn}
\begin{rightcolumn}
\includegraphics[width=\linewidth]{graphic.png}
\end{rightcolumn}
\end{paracol}
\begin{subparts}
\setcounter{subpart}{\value{subpartscounter}}
\subpart \Blindtext[1][3]
\begin{subsubparts}
\subsubpart[1] \Blindtext[1][3]
\subsubpart[1] \Blindtext[1][3]
\subsubpart[1] \Blindtext[1][3]
\end{subsubparts}
\end{subparts}
\begin{parts}
\setcounter{partno}{\value{partscounter}}
\part[1] \Blindtext[1][3]
\end{parts}
\end{questions}
\end{document}
它看起来是这样的:
以下是左栏中带有小页面的变体:
\documentclass[a4paper,
draft,
12pt]{exam}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[pangram]{blindtext}
\usepackage{graphicx}
\usepackage{paracol}
\pointformat{/\thepoints}
\addpoints
\pointsdroppedatright
%%%Exercises numbering%%%
%%% https://tex.stackexchange.com/questions/682327/exam-class-define-questionlabel-and-partlabel-conditionally/682446#682446 %%%
\makeatletter
\renewcommand{\thequestion}{\arabic{question}\@ifundefined{r@part@\arabic{question}@1}{\phantom{.0}}{.0}}
\renewcommand{\thepartno}{\arabic{question}.\arabic{partno}\@ifundefined{r@subpart@\arabic{question}@\arabic{partno}@1}{\phantom{.0}}{.0}}
\renewcommand{\thesubpart}{\arabic{question}.\arabic{partno}.\arabic{subpart}\@ifundefined{r@subsubpart@\arabic{question}@\arabic{partno}@\arabic{subpart}@1}{\phantom{.0}}{.0}}
\renewcommand{\thesubsubpart}{\arabic{question}.\arabic{partno}.\arabic{subpart}.\arabic{subsubpart}}
\renewcommand{\questionlabel}{\thequestion\hfill}
\renewcommand{\partlabel}{\hbox to \labelwidth{\thepartno\hfill}}
\renewcommand{\subpartlabel}{\hbox to \labelwidth{\thesubpart\hfill}}
\renewcommand{\subsubpartlabel}{\hbox to \labelwidth{\thesubsubpart\hfill}}
\renewcommand{\questionshook}{
\setlength{\leftmargin}{3em}
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\setlength{\linewidth}{\textwidth}
}
\renewcommand{\partshook}{
\setlength{\@totalleftmargin}{0pt}
\setlength{\leftmargin}{3em}
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\setlength{\linewidth}{\textwidth}
}
\renewcommand{\subpartshook}{
\setlength{\@totalleftmargin}{0pt}
\setlength{\leftmargin}{3em}
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\setlength{\linewidth}{\textwidth}
}
\renewcommand{\subsubpartshook}{
\setlength{\@totalleftmargin}{0pt}
\setlength{\leftmargin}{3em}
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\setlength{\linewidth}{\textwidth}
}
\makeatother
\newcounter{partscounter}
\newcounter{subpartscounter}
\newcounter{subsubpartscounter}
\begin{document}
\begin{questions}
\columnratio{0.6,0.4}
\begin{paracol}{2}
\begin{leftcolumn}
\begin{minipage}[c]{\linewidth}
\question \Blindtext[1][3]
\begin{parts}
\part \Blindtext[1][3]
\begin{subparts}
\subpart[1] \Blindtext[1][3]
\droppoints
\subpart[1] \Blindtext[1][3]
\setcounter{subpartscounter}{\value{subpart}}
\end{subparts}
\setcounter{partscounter}{\value{partno}}
\end{parts}
\end{minipage}
\end{leftcolumn}
\begin{rightcolumn}
\includegraphics[width=\linewidth]{graphic.png}
\end{rightcolumn}
\end{paracol}
\begin{subparts}
\setcounter{subpart}{\value{subpartscounter}}
\subpart \Blindtext[1][3]
\begin{subsubparts}
\subsubpart[1] \Blindtext[1][3]
\subsubpart[1] \Blindtext[1][3]
\subsubpart[1] \Blindtext[1][3]
\end{subsubparts}
\end{subparts}
\begin{parts}
\setcounter{partno}{\value{partscounter}}
\part[1] \Blindtext[1][3]
\end{parts}
\end{questions}
\end{document}
它看起来是这样的:
答案1
首先,3em 不够宽,特别是因为它包含了\labelsep
。其次,您应该设置\linewidth
为\columnwidth
,而不是\textwidth
。最后,窄列使用\sloppy
比\fussy
(默认)更适合连字符。
\documentclass[a4paper,
draft,
12pt]{exam}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[pangram]{blindtext}
\usepackage{graphicx}
\usepackage{paracol}
\pointformat{/\thepoints}
\addpoints
\pointsdroppedatright
%%%Exercises numbering%%%
%%% https://tex.stackexchange.com/questions/682327/exam-class-define-questionlabel-and-partlabel-conditionally/682446#682446 %%%
\makeatletter
\renewcommand{\thequestion}{\arabic{question}\@ifundefined{r@part@\arabic{question}@1}{\phantom{.0}}{.0}}
\renewcommand{\thepartno}{\arabic{question}.\arabic{partno}\@ifundefined{r@subpart@\arabic{question}@\arabic{partno}@1}{\phantom{.0}}{.0}}
\renewcommand{\thesubpart}{\arabic{question}.\arabic{partno}.\arabic{subpart}\@ifundefined{r@subsubpart@\arabic{question}@\arabic{partno}@\arabic{subpart}@1}{\phantom{.0}}{.0}}
\renewcommand{\thesubsubpart}{\arabic{question}.\arabic{partno}.\arabic{subpart}.\arabic{subsubpart}}
\renewcommand{\questionlabel}{\thequestion\hfill}
\renewcommand{\partlabel}{\hbox to \labelwidth{\thepartno\hfill}}
\renewcommand{\subpartlabel}{\hbox to \labelwidth{\thesubpart\hfill}}
\renewcommand{\subsubpartlabel}{\hbox to \labelwidth{\thesubsubpart\hfill}}
\renewcommand{\questionshook}{%
\setlength{\leftmargin}{4em}%
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\setlength{\linewidth}{\columnwidth}%
}
\renewcommand{\partshook}{%
\setlength{\@totalleftmargin}{0pt}%
\setlength{\leftmargin}{4em}%
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\setlength{\linewidth}{\columnwidth}%
}
\renewcommand{\subpartshook}{%
\setlength{\@totalleftmargin}{0pt}%
\setlength{\leftmargin}{4em}%
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\setlength{\linewidth}{\columnwidth}%
}
\renewcommand{\subsubpartshook}{%
\setlength{\@totalleftmargin}{0pt}%
\setlength{\leftmargin}{4em}%
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\setlength{\linewidth}{\columnwidth}%
}
\makeatother
\newcounter{partscounter}
\newcounter{subpartscounter}
\newcounter{subsubpartscounter}
\begin{document}
\begin{questions}
\columnratio{0.6,0.4}
\begin{paracol}{2}\sloppy
\begin{leftcolumn}
\question \Blindtext[1][3]
\begin{parts}
\part \Blindtext[1][3]
\begin{subparts}
\subpart[1] \Blindtext[1][3]
\droppoints
\subpart[1] \Blindtext[1][3]
\setcounter{subpartscounter}{\value{subpart}}
\end{subparts}
\setcounter{partscounter}{\value{partno}}
\end{parts}
\end{leftcolumn}
\begin{rightcolumn}
\includegraphics[width=\linewidth]{graphic.png}
\end{rightcolumn}
\end{paracol}
\begin{subparts}
\setcounter{subpart}{\value{subpartscounter}}
\subpart \Blindtext[1][3]
\begin{subsubparts}
\subsubpart[1] \Blindtext[1][3]
\subsubpart[1] \Blindtext[1][3]
\subsubpart[1] \Blindtext[1][3]
\end{subsubparts}
\end{subparts}
\begin{parts}
\setcounter{partno}{\value{partscounter}}
\part[1] \Blindtext[1][3]
\end{parts}
\end{questions}
\end{document}
此版本使用所需的最小宽度(假设问题数量可以超过 9,但不超过 20_。
\documentclass[a4paper,
draft,
12pt]{exam}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[pangram]{blindtext}
\usepackage{graphicx}
\usepackage{paracol}
\pointformat{/\thepoints}
\addpoints
\pointsdroppedatright
%%%Exercises numbering%%%
%%% https://tex.stackexchange.com/questions/682327/exam-class-define-questionlabel-and-partlabel-conditionally/682446#682446 %%%
\makeatletter
\renewcommand{\thequestion}{\arabic{question}\@ifundefined{r@part@\arabic{question}@1}{\phantom{.0}}{.0}}
\renewcommand{\thepartno}{\arabic{question}.\arabic{partno}\@ifundefined{r@subpart@\arabic{question}@\arabic{partno}@1}{\phantom{.0}}{.0}}
\renewcommand{\thesubpart}{\arabic{question}.\arabic{partno}.\arabic{subpart}\@ifundefined{r@subsubpart@\arabic{question}@\arabic{partno}@\arabic{subpart}@1}{\phantom{.0}}{.0}}
\renewcommand{\thesubsubpart}{\arabic{question}.\arabic{partno}.\arabic{subpart}.\arabic{subsubpart}}
\renewcommand{\questionlabel}{\thequestion\hfill}
\renewcommand{\partlabel}{\hbox to \labelwidth{\thepartno\hfill}}
\renewcommand{\subpartlabel}{\hbox to \labelwidth{\thesubpart\hfill}}
\renewcommand{\subsubpartlabel}{\hbox to \labelwidth{\thesubsubpart\hfill}}
\newcommand{\multihook}{%
\setlength{\@totalleftmargin}{0pt}%
\settowidth{\labelwidth}{12.2.2.2}% 2 is usually the widest digit, 1 is narrowest
\setlength{\leftmargin}{\dimexpr \labelwidth+\labelsep}%
\setlength{\linewidth}{\columnwidth}%
}
\let\questionshook=\multihook
\let\partshook=\multihook
\let\subpartshook=\multihook
\let\subsubpartshook=\multihook
\makeatother
\newcounter{partscounter}
\newcounter{subpartscounter}
\newcounter{subsubpartscounter}
\begin{document}
\begin{questions}
\columnratio{0.6,0.4}
\begin{paracol}{2}\sloppy
\begin{leftcolumn}
\question \Blindtext[1][3]
\begin{parts}
\part \Blindtext[1][3]
\begin{subparts}
\subpart[1] \Blindtext[1][3]
\droppoints
\subpart[1] \Blindtext[1][3]
\setcounter{subpartscounter}{\value{subpart}}
\end{subparts}
\setcounter{partscounter}{\value{partno}}
\end{parts}
\end{leftcolumn}
\begin{rightcolumn}
\includegraphics[width=\linewidth]{graphic.png}
\end{rightcolumn}
\end{paracol}
\begin{subparts}
\setcounter{subpart}{\value{subpartscounter}}
\subpart \Blindtext[1][3]
\begin{subsubparts}
\subsubpart[1] \Blindtext[1][3]
\subsubpart[1] \Blindtext[1][3]
\subsubpart[1] \Blindtext[1][3]
\end{subsubparts}
\end{subparts}
\begin{parts}
\setcounter{partno}{\value{partscounter}}
\part[1] \Blindtext[1][3]
\end{parts}
\end{questions}
\end{document}
答案2
我找到了一个解决方法:在每个项目周围创建一个不同的 paracol 环境,让右列为空。然后将图形添加到最后一个 paracol 的右列中,并使用负 \vspace* 将其向上移动。这不是最优雅的解决方案,但它有效。不过,正在寻找更好的解决方案!