我想要 XSIM 问题,其中包含正常数字。我试过了,但没有得到正确的缩进。如何才能获得正确的缩进,如下图所示。我可以使用考试类来获得,但我希望使用 XSIM。
我的MWE
\documentclass[a4paper,12pt]{article}
\usepackage{xsim}
\usepackage{tasks}
\usepackage{needspace}
\DeclareExerciseEnvironmentTemplate{custom}
{%
\par\vspace{\baselineskip}
\noindent
{\GetExerciseProperty{counter}.~}%
\IfInsideSolutionF{%
\GetExercisePropertyT{points}{%
\marginpar{%
[\printgoal{\PropertyValue}%
\GetExercisePropertyT{bonus-points}{+\printgoal{\PropertyValue}}]%
}%
}%
}%
}
{}
\NewTasksEnvironment[
label = (\theexercise.\arabic*) ,
% label-format = \bfseries ,
label-width = 35pt,
item-indent=55pt
]{parts}[\part]
\xsimsetup{
exercise/template = custom ,
solution/template = custom
}
\usepackage{lipsum}
\begin{document}
\begin{exercise}[points=4]
\lipsum[1]
\end{exercise}
\begin{solution}
\lipsum[1]
\end{solution}
\begin{exercise}
Answer the following questions.
\begin{parts}
\part \lipsum[1]
\part question
\end{parts}
\end{exercise}
\begin{exercise}
\lipsum[1]
\end{exercise}
\begin{solution}
\lipsum[1]
\end{solution}
\printsolutions
\end{document}
答案1
一种方法是使用描述列表环境,其中每个问题(或解决方案)都是一个项目。使用包可以轻松配置描述列表以进行悬挂缩进enumitem
。
编译两次。<<<
\documentclass[a4paper,12pt]{article}
\usepackage{xsim}
\usepackage{tasks}
\usepackage{needspace}
\usepackage{enumitem}% added<<<<<<<<<<<<<
\usepackage{marginnote}% added<<<<<<<<<<<<<
\NewTasksEnvironment[
label = (\theexercise.\arabic*) ,
% label-format = \bfseries ,
label-width = 5ex,
item-indent=6ex
]{parts}[\part]
\DeclareExerciseEnvironmentTemplate{custom}% changed <<<<<<<<<<<<<<
{\item[\normalfont\GetExerciseProperty{counter}.]\IfInsideSolutionF{%
\GetExercisePropertyT{points}{%
\marginnote{%
[\printgoal{\PropertyValue}\GetExercisePropertyT{bonus-points}{+\printgoal{\PropertyValue}}]%
}}}
}{}
\xsimsetup{
exercise/template = custom,
solution/template = custom
}
\newenvironment{exercises}{% added <<<<<<<<<<<<
\begin{description}[labelwidth= 3ex, leftmargin=!]}{\end{description}}
\newenvironment{solutions}{% added <<<<<<<<<<<<
\begin{description}[labelwidth= 3ex, leftmargin=!]}{\end{description}}
\usepackage{lipsum}
\begin{document}
\begin{exercises} % added <<<<<<<<<<<<<<<
\begin{exercise}[points=4]
\lipsum[1]
\end{exercise}
\begin{solution}
\lipsum[1]
\end{solution}
\begin{exercise}
Answer the following questions.
\begin{parts}
\part \lipsum[1]
\part question.
\end{parts}
\end{exercise}
\begin{exercise}
\lipsum[1]
\end{exercise}
\begin{solution}
\lipsum[1]
\end{solution}
\end{exercises} %<<<<<<<<<<<<<<<<
\begin{solutions}% added <<<<<<<<<<<<<<<
\printsolutions
\end{solutions}%<<<<<<<<<<<<<<<
\end{document}