我正在使用 xsim 套件來建立練習集。有些練習立即從 (a)、(b) 等部分開始,沒有介紹文字。我使用了這裡的其他答案來設定 enumitem 列表,其中 topsep = 0pt 和「之前」的負 vspace 。這在大多數情況下似乎都很好,但本例中的練習 2 除外,其中上標似乎會影響垂直對齊。
是否有更好的方法來設定枚舉列表,以便 (a) 部分始終與練習編號正確對齊?
\documentclass[a4paper,11pt]{memoir}
\usepackage[T1]{fontenc}
\usepackage[defaultsans]{opensans}
\usepackage{newtxtext,newtxmath}
\setlength{\parskip}{0.6em}
\setlength{\parindent}{0pt}
\usepackage{xsim}
\DeclareExerciseEnvironmentTemplate{margin} % simulate margin-nr style from exsheets
{%
\par\vspace{\baselineskip}
\Needspace*{2\baselineskip}
\noindent
\llap{%
\smash{%
\tabular[t]{@{}r@{}}
\sffamily\textbf{\GetExerciseProperty{counter}\,}
\endtabular
} % notice the space
}%
}
{}
\xsimsetup{
exercise/template = margin,
solution/template = margin
}
\usepackage{enumitem}
\newlist{exampartsnoskip}{enumerate}{2}
\setlist[exampartsnoskip]{topsep=0pt,before={\vspace*{-1.85em}},label={(\alph*)},itemsep=0.1em,leftmargin=\oddsidemargin}
\setlist[exampartsnoskip,1]{label=(\alph*)}
\begin{document}
\begin{exercise}
\begin{exampartsnoskip}
\item First
\item Second
\end{exampartsnoskip}
\end{exercise}
\begin{exercise}
\begin{exampartsnoskip}
\item Evaluate $\left(36^\frac12+16^\frac14\right)^\frac13$
\item Second
\end{exampartsnoskip}
\end{exercise}
\begin{exercise}
\begin{exampartsnoskip}
\item $\dfrac{x}{\dfrac{1}{x+1}}$
\item Second
\end{exampartsnoskip}
\end{exercise}
\end{document}
答案1
也許margin
用以下方法實作模板trivlist
:
\documentclass[a4paper,11pt]{memoir}
\usepackage[T1]{fontenc}
\usepackage[defaultsans]{opensans}
\usepackage{newtxtext,newtxmath}
\setlength{\parskip}{0.6em}
\setlength{\parindent}{0pt}
\usepackage{showframe}
\usepackage{xsim}
\DeclareExerciseEnvironmentTemplate{margin}{%
\trivlist
\item[\llap{\sffamily\textbf{\GetExerciseProperty{counter}}}]\relax
}
{\endtrivlist}
\xsimsetup{
exercise/template = margin,
solution/template = margin
}
\usepackage{enumitem}
\newlist{examparts}{enumerate}{2}
\setlist[examparts]{
topsep=0pt,
% before={\vspace*{-1.85\baselineskip}},
label={(\alph*)},
itemsep=0.1em,
leftmargin=\oddsidemargin
}
\setlist[examparts,1]{label=(\alph*)}
\begin{document}
\begin{exercise}
\begin{examparts}
\item First
\item Second
\end{examparts}
\end{exercise}
\begin{exercise}
\begin{examparts}
\item Evaluate $\left(36^\frac12+16^\frac14\right)^\frac13$
\item Second
\end{examparts}
\end{exercise}
\begin{exercise}
\begin{examparts}
\item $\dfrac{x}{\dfrac{1}{x+1}}$
\item Second
\end{examparts}
\end{exercise}
\end{document}
答案2
如果您希望內部表達式的過大高度影響外部標籤編號的位置,您需要延遲設定該數字,然後將其貼到內部標籤上。預設情況下,LaTeX 對嵌套清單執行類似的操作,但這裡我只是手動執行。
\documentclass[a4paper,11pt]{memoir}
\usepackage[T1]{fontenc}
\usepackage[defaultsans]{opensans}
\usepackage{newtxtext,newtxmath}
\setlength{\parskip}{0.6em}
\setlength{\parindent}{0pt}
\usepackage{xsim}
\DeclareExerciseEnvironmentTemplate{margin} % simulate margin-nr style from exsheets
{%
\par\vspace{\baselineskip}
\Needspace*{2\baselineskip}
\protected\gdef\exno{\llap{%
\sffamily\textbf{\GetExerciseProperty{counter}\,} }% notice the space
\gdef\exno{}}%
}
{}
\xsimsetup{
exercise/template = margin,
solution/template = margin
}
\usepackage{enumitem}
\newlist{exampartsnoskip}{enumerate}{2}
\setlist[exampartsnoskip]{topsep=0pt,before={\vspace*{-1.85em}},label={(\alph*)},itemsep=0.1em,leftmargin=\oddsidemargin}
\setlist[exampartsnoskip,1]{label=\exno(\alph*)}
\begin{document}
\begin{exercise}
\begin{exampartsnoskip}
\item First
\item Second
\end{exampartsnoskip}
\end{exercise}
\begin{exercise}
\begin{exampartsnoskip}
\item Evaluate $\left(36^\frac12+16^\frac14\right)^\frac13$
\item Second
\end{exampartsnoskip}
\end{exercise}
\begin{exercise}
\begin{exampartsnoskip}
\item $\dfrac{x}{\dfrac{1}{x+1}}$
\item Second
\end{exampartsnoskip}
\end{exercise}
\end{document}