我想使用 probsoln 更改考试问题的编号。目前,它只是将每个问题直接放在彼此下方,并将其编号为列表。我希望它看起来像这样:
问题:问题 1
无论问题是什么。
问题 : Vraag 2
另一个问题
ETC
这是我一直在使用的代码,但是无法让它改变编号:
\documentclass[a4paper]{report}
\usepackage{probsoln}
\loadallproblems{prob-easy}
\showanswers
\begin{document}
\begin{enumerate}
\foreachproblem{\item \thisproblem}
\end{enumerate}
\end{document}
\endinput
非常感谢您的帮助!
答案1
这可以通过多种方式实现;首先,不需要额外的包,您可以(本地)重新定义\labelenumi
:
\documentclass[a4paper]{report}
\usepackage{probsoln}
\loadallproblems{prob-easy}
\showanswers
\begin{document}
\begingroup
\renewcommand\labelenumi{\textbf{Question : Vraag \arabic{enumi}}}
\begin{enumerate}
\foreachproblem{\item\thisproblem}
\end{enumerate}
\endgroup
\end{document}
您还可以借助enumitem
包裹:
\documentclass[a4paper]{report}
\usepackage{probsoln}
\usepackage{enumitem}
\loadallproblems{prob-easy}
\showanswers
\begin{document}
\begin{enumerate}[label=\bfseries Question : Vraag \arabic*]
\foreachproblem{\item\thisproblem}
\end{enumerate}
\end{document}
或者,定义一个专用列表:
\documentclass[a4paper]{report}
\usepackage{probsoln}
\usepackage{enumitem}
\newlist{myproblems}{enumerate}{4}
\setlist[myproblems,1]{label=\bfseries Question : Vraag \arabic*}
\loadallproblems{prob-easy}
\showanswers
\begin{document}
\begin{myproblems}
\foreachproblem{\item\thisproblem}
\end{myproblems}
\end{document}
prob-easy.tex
我的示例中使用的文件:
\begin{defproblem}{cosxsqsinx}%
\begin{onlyproblem}%
$y = \cos(x^2)\sin x$.%
\end{onlyproblem}%
\begin{onlysolution}%
\[\frac{dy}{dx} = -\sin(x^2)2x\sin x + \cos(x^2)\cos x\]
\end{onlysolution}%
\end{defproblem}
\begin{defproblem}{sinxsqsinx}%
\begin{onlyproblem}%
$y = \cos(x^2)\sin x$.%
\end{onlyproblem}%
\begin{onlysolution}%
\[\frac{dy}{dx} = -\sin(x^2)2x\sin x + \cos(x^2)\cos x\]
\end{onlysolution}%
\end{defproblem}
更新
在评论中,有人要求将每个问题的标题放在一行的中心位置;这是一种可能性:
\documentclass[a4paper]{report}
\usepackage{probsoln}
\newcounter{myprob}
\newenvironment{myproblems}
{\par\setcounter{myprob}{0}}
{\par}
\newcommand\MyProb{%
{\par\medskip\centering\refstepcounter{myprob}\bfseries Question : Vraag \arabic{myprob}\par\nobreak}%
}
\loadallproblems{prob-easy}
%\showanswers
\begin{document}
\begin{myproblems}
\foreachproblem{\MyProb\thisproblem}
\end{myproblems}
\end{document}
这是prob-easy.tex
:
\begin{defproblem}{cosxsqsinx}%
\begin{onlyproblem}%
$y = \cos(x^2)\sin x$.%
\end{onlyproblem}%
\begin{onlysolution}%
\[\frac{dy}{dx} = -\sin(x^2)2x\sin x + \cos(x^2)\cos x\]
\end{onlysolution}%
\end{defproblem}
\begin{defproblem}{texttest}%
\begin{onlyproblem}%
Some text for the example. so the problem will have text and not necessarily a math expression.%
\end{onlyproblem}%
\begin{onlysolution}%
\[\frac{dy}{dx} = -\sin(x^2)2x\sin x + \cos(x^2)\cos x\]
\end{onlysolution}%
\end{defproblem}
\begin{defproblem}{sinxsqsinx}%
\begin{onlyproblem}%
$y = \cos(x^2)\sin x$.%
\end{onlyproblem}%
\begin{onlysolution}%
\[\frac{dy}{dx} = -\sin(x^2)2x\sin x + \cos(x^2)\cos x\]
\end{onlysolution}%
\end{defproblem}