接下来是这个问题:Exsheets:使用任务改进子问题分数特征。是否可以自动生成具有以下方面的表格:
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}{|l|l|l|l|l|}
\hline
\multicolumn{2}{|c|}{Question} & \multicolumn{2}{c|}{Points} & Notes \\ \hline
1 & 1.1 & 4 & 1 & \\ \cline{2-2} \cline{4-5}
& 1.2 & & 1 & \\ \cline{2-2} \cline{4-5}
& 1.3 & & 2 & \\ \hline
2 & 2.1 & 3 & 1.5 & \\ \cline{2-2} \cline{4-5}
& 2.2 & & 1.5 & \\ \hline
\multicolumn{2}{|l|}{Total} & \multicolumn{2}{r|}{7} & \\ \hline
\end{tabular}
\end{document}
表格中的代码几乎可以做到这一点,但我认为如果有一种方法可以像处理问题一样从子问题中获取属性,那么会更容易。我说的是定义两个新命令\SubQuestionNumber{#1}
和\GetQuestionProperty{subpoints}{#1}
(都在里面使用\ForEachQuestion{}
),这样\SubQuestionNumber{#1}
会返回每个问题中的子问题数量(标签?)以及\GetQuestionProperty{subpoints}{#1}
每个子问题的分数。
答案1
您可以调整链接问题中的代码,以获得与您发布的表格类似的内容。我在下面注释了代码,希望您能清楚地了解所有内容的作用。它生成此成绩表:
\documentclass[10pt,a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[pass,showframe]{geometry}
\usepackage{array,booktabs}
\usepackage{marginnote}
\usepackage{blindtext}
\usepackage[load-headings]{exsheets}
\SetupExSheets{
solution/print = true,
headings = block-wp,
counter-format = qu
}
% this requires version 0.9 of tasks.sty:
\settasks{
counter-format = qu.tsk ,
label-width = 2em
}
\usepackage{etoolbox,expl3,xparse}
% declare` subpoints' and `subnumber' properties:
\DeclareQuestionProperty{subpoints}
\DeclareQuestionProperty{subnumber}
% switch to expl3 namespace and make @ a letter:
\makeatletter
\ExplSyntaxOn
% declare a temporary sequence variable for each property:
\seq_new:N \g_cacamailg_subpoints_seq
\seq_new:N \g_cacamailg_subnumber_seq
% the following assumes you're always going to use a {tasks}
% environment for the subquestions
\cs_new_protected:Npn \cacamailg_subpoints:n #1
{
% save the points in the one sequence...
\seq_gput_right:Nx \g_cacamailg_subpoints_seq { #1 }
% ... and the current current {tasks} label in the other:
\seq_gput_right:Nx \g_cacamailg_subnumber_seq
{ \@cntfmts@parsed@pattern }
% \addpoints adds the points to the current question points
% and the total sum of points:
\marginnote { \addpoints { #1 } }
\ignorespaces
}
\NewDocumentCommand \subpoints { m }
{ \cacamailg_subpoints:n { #1 } }
\cs_generate_variant:Nn \exsheets_set_question_properties:n { x }
% at the end of a {question}:
\AtEndEnvironment{question}
{
% are subpoints given?
\seq_if_empty:NF \g_cacamailg_subpoints_seq
{
% then build a table of the subpoints and another one of the subpoints
% to be used in the grade table later and save them both as question
% property:
\exsheets_set_question_properties:x
{
subpoints =
{
\exp_not:N \begin{tabular}[t]{@{}l@{}}
\seq_use:Nnnn \g_cacamailg_subpoints_seq {\\} {\\} {\\}
\exp_not:N \end{tabular}
} ,
subnumber =
{
\exp_not:N \begin{tabular}[t]{@{}l@{}}
\seq_use:Nnnn \g_cacamailg_subnumber_seq {\\} {\\} {\\}
\exp_not:N \end{tabular}
}
}
}
% clear both sequences:
\seq_gclear:N \g_cacamailg_subpoints_seq
\seq_gclear:N \g_cacamailg_subnumber_seq
}
\ExplSyntaxOff
\makeatother
\begin{document}
\begin{question}
\begin{tasks}
\task \subpoints{1} \blindtext
\task \subpoints{0.5} \blindtext
\task \subpoints{1} \blindtext
\task \subpoints{1} \blindtext
\end{tasks}
\end{question}
\begin{question}
\begin{tasks}
\task \subpoints{0.75} \blindtext
\task \subpoints{0.75} \blindtext
\task \subpoints{1.5} \blindtext
\end{tasks}
\end{question}
\null\vspace*{\fill}
\begin{center}
\begin{tabular}{|*4{l|}c|}\hline
\multicolumn{2}{|c|}{Question } & \multicolumn{2}{c|}{ Points } & Notes \\ \hline
\ForEachQuestion{
\QuestionNumber{#1} &
\GetQuestionProperty{subnumber}{#1} &
\GetQuestionProperty{points}{#1} &
\GetQuestionProperty{subpoints}{#1} &
\iflastquestion{}{\tabularnewline\hline}
}
\\\hline
\multicolumn{2}{|l|}{Total} & \multicolumn{2}{r|}{\pointssum* } &\\\hline
\end{tabular}
\end{center}
\end{document}