我在嵌套列表的格式方面遇到了一点问题。 (b) (i) 和 (c) (i) 似乎有重叠。不过,同一问题的答案中的格式没有问题。我不确定为什么会发生这种情况。以下是基于这个答案
\documentclass{book}
\usepackage{newfile}
\usepackage{amsmath}
\usepackage{xifthen}
\usepackage{enumitem}
\usepackage{multicol}
\setlength{\parindent}{0pt}
\newoutputstream{solutions}
\openoutputfile{\jobname.solutions}{solutions}
\newcounter{exblock}
\newlist{exercises}{enumerate}{3}
\setlist[exercises]{font=\bfseries}
% \setlist[exercises,1]{label=\arabic*.}% format in MWE
\setlist[exercises,1]{label=Q\arabic*}% requested format
\setlist[exercises,2]{label=(\alph*),noitemsep}
\setlist[exercises,3]{label=(\roman*),noitemsep}
\newlist{solutions}{enumerate}{3}
\setlist[solutions]{font=\bfseries}
% \setlist[solutions,1]{label=\arabic*.}% format in MWE
\setlist[solutions,1]{label=Q\arabic*}% requested format
\setlist[solutions,2]{label=(\alph*),noitemsep}
\setlist[solutions,3]{label=(\roman*),noitemsep}
\newcommand{\exheader}{%
\ifthenelse{\value{exblock}>0}{%
\addtostream{solutions}{%
\noexpand\end{solutions}%
}%
}{}%
\refstepcounter{exblock}%
\section{Exercises}%
\label{ex.\arabic{exblock}}%
\addtostream{solutions}{%
\noexpand\paragraph{Exercises \noexpand\ref{ex.\arabic{exblock}}, page \noexpand\pageref{ex.\arabic{exblock}}}%
}
\addtostream{solutions}{\noexpand\begin{solutions}}%
}
\newcommand{\printsolutions}{%
\ifthenelse{\value{exblock}>0}{%
\addtostream{solutions}{\noexpand\end{solutions}}%
}{}%
\closeoutputstream{solutions}%
\input{\jobname.solutions}%
}
\newcommand{\question}[2]{%
\item \label{ex.\arabic{exblock}.\arabic{exercisesi}} #1%
\addtostream{solutions}{\noexpand\item[\noexpand\ref{ex.\arabic{exblock}.\arabic{exercisesi}}] #2}%
}
\newenvironment{subquestions}[1][]{%
\item \label{ex.\arabic{exblock}.\arabic{exercisesi}} #1%
\addtostream{solutions}{%
\noexpand\item[\noexpand\ref{ex.\arabic{exblock}.\arabic{exercisesi}}]\noexpand\begin{solutions}%
}%
\begin{exercises}%
}{%
\end{exercises}%
\addtostream{solutions}{\noexpand\end{solutions}}%
}
\newcommand{\subquestion}[2]{%
\item\label{ex.\arabic{exblock}.\arabic{exercisesi}.\arabic{exercisesii}} #1
\addtostream{solutions}{\noexpand\item[\noexpand\ref{ex.\arabic{exblock}.\arabic{exercisesi}.\arabic{exercisesii}}] #2}%
}
\newenvironment{subparts}[1][]{%
\item \label{ex.\arabic{exblock}.\arabic{exercisesi}.\arabic{exercisesii}} #1%
\addtostream{solutions}{%
\noexpand\item[\noexpand\ref{ex.\arabic{exblock}.\arabic{exercisesi}.\arabic{exercisesii}}]\noexpand\begin{solutions}%
}%
\begin{exercises}%
}{%
\end{exercises}%
\addtostream{solutions}{\noexpand\end{solutions}}%
}
\newcommand{\subpart}[2]{%
\item\label{ex.\arabic{exblock}.\arabic{exercisesi}.\arabic{exercisesii}.\arabic{exercisesiii}} #1
\addtostream{solutions}{\noexpand\item[\noexpand\ref{ex.\arabic{exblock}.\arabic{exercisesi}.\arabic{exercisesii}.\arabic{exercisesiii}}] #2}%
}
\begin{document}
\chapter{First Chapter}
\exheader
\begin{exercises}
\question{This is a test question}{solution 1}
\begin{subquestions}
\subquestion{testing1a}{testing answer1}
\subquestion{testing1b}{testing answer2}
\subquestion{testing1c}{testing answer3}
\begin{subparts}
\subpart{First Sub Part}{First Subpart answer}
\subpart{Second Sub Part}{Second Subpart answer}
\subpart{Third Sub Part}{Third Subpart answer}
\end{subparts}
\subquestion{testing1e}{testing answer3}
\end{subquestions}
\begin{subquestions}
\begin{subparts}
\subpart{arg1}{arg2}
\subpart{arg1}{arg2}
\subpart{arg1}{arg2}
\subpart{arg1}{arg2}
\end{subparts}
\begin{subparts}
\subpart{arg1}{arg2}
\subpart{arg1}{arg2}
\subpart{arg1}{arg2}
\subpart{arg1}{arg2}
\end{subparts}
\begin{subparts}
\subpart{arg1}{arg2}
\subpart{arg1}{arg2}
\subpart{arg1}{arg2}
\subpart{arg1}{arg2}
\end{subparts}
\end{subquestions}
\end{exercises}
\chapter{Appendix}
\section{Solutions}
\printsolutions
\end{document}