\answergrid 的新样式:

\answergrid 的新样式:

您能否帮助我使用代码在下图中获得以下样式\answergrid::

在此处输入图片描述

谢谢!

答案1

这是对以下代码的改编:https://tex.stackexchange.com/a/285086/46716

\documentclass{article}
\usepackage{tikz}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\answergrid}{ O{1} m m m }{
    \begin{tikzpicture}[box/.style={draw,minimum~width=7mm,minimum~height=4mm},y=.5cm]
        \seq_set_split:Nnn \l_tmpa_seq{;}{#4}
        \int_step_inline:nnnn {#1} {1} {#1+#2-1} {
            \node[box] at (##1+1-#1,#3+.5) {##1};
            \int_step_inline:nnnn {1} {1} {#3} {
                \int_compare:nNnTF {####1} = {\seq_item:Nn \l_tmpa_seq {##1-#1+1}} {
                    \node[box,fill=green] at (##1+1-#1, #3-####1) {\int_to_Alph:n{####1}};
                }{
                    \node[box] at (##1+1-#1, #3-####1) {\int_to_Alph:n{####1}};
                }
            }
        }
    \end{tikzpicture}
}
\ExplSyntaxOff

\begin{document}

    \sffamily\small

    \answergrid      {10} {4} {1;2;4;3;2;3;1;2;3;4}

    \vspace*{1cm}

    \answergrid [11] {10} {4} {1;2;4;3;2;3;1;2;1;2}

\end{document}

在此处输入图片描述

相关内容