有没有办法tabularray
使用xsim
ExerciseTableTemplate
我复制了默认模板来自 xsim,仅用 which 替换tabular
会tblr
导致我无法理解的错误:
\documentclass{article}
\usepackage{xsim,tabularray,expl3}
\UseTblrLibrary{booktabs}
\ExplSyntaxOn
\DeclareExerciseTableTemplate {mydefault}
{
\XSIMputright \ExerciseTableCode
{
\toprule
\XSIMifblankF { \ExerciseType }
{ \XSIMmixedcase { \GetExerciseParameter {exercise-name} } }
&
\XSIMmixedcase { \XSIMtranslate {points} } &
\XSIMtranslate {reached} \\
\midrule
}
\ForEachUsedExerciseByOrder
{
\XSIMifeqT {#1} { \ExerciseTableType {#1} }
{
\XSIMifblankT { \ExerciseTableType {} }
{
\XSIMputright \ExerciseTableCode
{
\XSIMmixedcase
{ \ExerciseParameterGet {#1} {exercise-name} ~ }
}
}
\XSIMputright \ExerciseTableCode
{ #3 & \XSIMifblankTF {#5} {\printgoal{0}} {\printgoal{#5}} & \\ }
}
}
\XSIMputright \ExerciseTableCode
{
\midrule
\XSIMtranslate {total} &
\XSIMifblankTF { \ExerciseType }
{ \TotalExerciseGoal {points} {} {} }
{ \TotalExerciseTypeGoal { \ExerciseType } {points} {} {} } &
\\ \bottomrule
}
\XSIMexpandcode
{
\noexpand \begin {tblr} {\XSIMifblankTF{\ExerciseType}{l}{c}cc}
\noexpand \ExerciseTableCode
\noexpand \end {tblr}
}
}
\ExplSyntaxOff
\begin{document}
\gradingtable[template=mydefault]
\begin{exercise}[points=4,bonus-points=1]
A first example for an exercise.
\end{exercise}
\end{document}
错误:对齐制表符 & 放错位置。
答案1
使用tabularray
的expand
选项。替换
\XSIMexpandcode
{
\noexpand \begin {tblr} {\XSIMifblankTF{\ExerciseType}{l}{c}cc}
\noexpand \ExerciseTableCode
\noexpand \end {tblr}
}
经过
\XSIMexpandcode
{
\noexpand \begin {tblr} [expand=\noexpand\ExerciseTableCode] {\XSIMifblankTF{\ExerciseType}{l}{c}cc}
\noexpand \ExerciseTableCode
\noexpand \end {tblr}
}
或
\XSIMifblankTF{\ExerciseType}
{ \begin {tblr} [expand=\ExerciseTableCode] {lcc} }
{ \begin {tblr} [expand=\ExerciseTableCode] {ccc} }
\ExerciseTableCode
\end {tblr}
tabularray
抱怨“不可扩展”\XSIMifblankTF
很奇怪,因为\XSIMifblankTF
实际上是完全可扩展的,但是......