在 xsim 模板中使用 tabularray

在 xsim 模板中使用 tabularray

有没有办法tabularray使用xsim ExerciseTableTemplate我复制了默认模板来自 xsim,仅用 which 替换tabulartblr导致我无法理解的错误:

\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

使用tabularrayexpand选项。替换

\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实际上是完全可扩展的,但是......

相关内容