我如何将具有两列的枚举添加到类似 tabularray 的任务包中?

我如何将具有两列的枚举添加到类似 tabularray 的任务包中?

我正在使用任务包

\begin{tasks}[label = \alph*)](2)
    \task $x^2 + x - 2 = 0$
    \task $x^2 + x - 2 = 0$
    \end{tasks}

我该如何将其变成tabularray。我必须手动完成

\documentclass[12pt,a4paper]{article}
\usepackage[hmargin=1.7cm, vmargin={1.8cm,1.7cm}]{geometry}
\usepackage{fouriernc}
\usepackage{tasks}
\usepackage{ninecolors}
\usepackage{tabularray}
\UseTblrLibrary{amsmath, booktabs, counter,
    diagbox, siunitx,  varwidth}
\sisetup{output-decimal-marker={,}}
\DefTblrTemplate{contfoot-text}{normal}{}
\SetTblrTemplate{contfoot-text}{normal}
\DefTblrTemplate{conthead-text}{normal}{}
\SetTblrTemplate{conthead-text}{normal}
\DefTblrTemplate{caption-tag}{normal}{}
\DefTblrTemplate{caption-sep}{normal}{}
\DefTblrTemplate{caption-text}{normal}{}
\SetTblrTemplate{caption-tag}{normal}{}
\SetTblrTemplate{caption-sep}{normal}{}
\SetTblrTemplate{caption-text}{normal}{}

\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{enumitem}



\newcounter{prob}
\NewTableCommand\problem[1]{\SetRow{bg=gray9}%
    \SetCell[r=#1]{h, cmd={\stepcounter{prob}\theprob}, bg=white}}

\begin{document}
    I am using task package
    \begin{tasks}[label = \alph*)](2)
    \task $x^2 + x - 2 = 0$
    \task $x^2 + x - 2 = 0$
    \end{tasks}
    \begin{longtblr}[
        caption={Answer}]{hlines, vlines,
            colspec = {Q[c, h, font=\bfseries] X[valign=h] Q[c, si={table-format=1.2}]},
            cell{1}{2-3}={halign=c},
            row{1} = {yellow9, font=\bfseries, mode=text},
            rowsep = 5pt,
            rowhead = 1,
        } 
    Problem & Content  & Point    \\
        \problem{1} &   Prolbem 1
        
        a)  $x^2 + x - 2 = 0$ \quad  b) $x^2 + x - 2 = 0$ &1,00
    \end{longtblr} 
\end{document}

在此处输入图片描述

使用tasks,我可以通过在此代码中将 2 更改为另一个数字来设置列数。

\begin{tasks}[label = \alph*)](2)
        \task $x^2 + x - 2 = 0$
        \task $x^2 + x - 2 = 0$
        \end{tasks}

答案1

请尝试以下操作:

\documentclass[12pt,a4paper]{article}
\usepackage[hmargin=1.7cm, vmargin={1.8cm,1.7cm}]{geometry}
\usepackage{fouriernc}
\usepackage{tasks}
\usepackage{ninecolors}
\usepackage{tabularray}
\UseTblrLibrary{amsmath, booktabs, counter,
                diagbox, siunitx,  varwidth}

\begin{document}
I am using task package
    \begin{tasks}[label = \alph*)](2)
\task $x^2 + x - 2 = 0$
\task $x^2 + x - 2 = 0$
    \end{tasks}
    
\begin{longtblr}[
caption={Answer}]{hlines, vlines,
                  colspec = {Q[c, h, font=\bfseries] 
                             X[h, preto=\begin{minipage}{\linewidth}, appto=\end{minipage}] 
                             Q[c, si={table-format=1.2}]},
                  cell{2-Z}{1} = {cmd=\the\numexpr\arabic{rownum}-1},
                  row{1} = {c, bg=yellow9, font=\bfseries, mode=text},
                  rowsep = 5pt,
                  hspan=minimal,
                  rowhead = 1,
    }
Problem & \centering Content  & Point    \\
    &   \begin{tasks}[label = \alph*)](2)
    \task $x^2 + x - 2 = 0$
    \task $x^2 + x - 2 = 0$
        \end{tasks}
        &   1,00                \\
    &   \begin{tasks}[label = \alph*)](2)
    \task $x^2 + x - 2 = 0$
    \task $x^2 + x - 2 = 0$
    \task $x^2 + x - 2 = 0$
    \task $x^2 + x - 2 = 0$
    \task $x^2 + x - 2 = 0$
    \task $x^2 + x - 2 = 0$
        \end{tasks}
        &   1,00                \\
\end{longtblr}
\end{document}

(我将您的文档示例简化为 MWE,您可以自己添加标题格式的问题)。

在此处输入图片描述

相关内容