3

I would like to have two commands that automate the generation of both vertical and horizontal grading tables to look the same as those manually written by me below.

enter image description here

\documentclass[a4paper,addpoints,11pt]{exam} 

\marksnotpoints

\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}

\vqword{Question}
\vpword{Marks}

\begin{document}
    
    \begin{coverpages}
        
    \begin{tblr}
        [
        presep = 0pt, headsep = 0pt,
        footsep = 0pt, postsep = 0pt,
        ]{
            colsep = 1 em,
            column{1} = {0.15\linewidth},
            width = 0.5\linewidth,
            colspec = {
                X[ c, 2 ]
                X[ c, 1.5 ]
                X[ c, 1.5 ]
            },
            hline{2-Z} = {0.25pt},
            vlines = {0.25pt},
            rows = {m},
            row{1} = {10ex, font = \bfseries},
            row{2-Z} = {6ex, m},
            row{Z} = {font = \bfseries},
            rulesep = 0pt,
            rowsep = 0ex,
        }
        \toprule[1.5pt]
        Question & Marks & Score \\
        1\textsuperscript{st} & 10 & \\
        2\textsuperscript{nd} & 20 & \\
        3\textsuperscript{rd} & 30 & \\
        Total & 60 & \\
        \bottomrule[1.5pt]
    \end{tblr}
    
    \bigskip
    
    \begin{tblr}
        [
        presep = 0pt, headsep = 0pt,
        footsep = 0pt, postsep = 0pt,
        ]{
            colsep = 1 em,
            column{1} = {0.15\linewidth, font = \bfseries},
            column{Z} = {font = \bfseries},
            width = 0.75\linewidth,
            colspec = {
                X[ l, 2 ]
                *{3}{X[ c, 1.5 ]}
                X[ c, 2 ]
            },
            hline{2-Z} = {0.25pt},
            vlines = {0.25pt},
            rows = {6ex, m},
            rulesep = 0pt,
            rowsep = 0ex,
        }
        \toprule[1.5pt]
        Question & 1\textsuperscript{st} & 2\textsuperscript{nd} & 3\textsuperscript{rd} & Total \\
        Marks & 10 & 20 & 30 & 60\\
        Score &  &  &  & \\
        \bottomrule[1.5pt]
    \end{tblr}

    \end{coverpages}

    \begin{questions}
        \question[10]
        Example question
        \question[20]
        Example question
        \question[30]
        Example question
    \end{questions}
    
\end{document}
2
  • @JohnKormylo I totally overlooked it. Sorry for that. Done
    – Diaa
    Commented Nov 11, 2021 at 14:48
  • The numbers are available from the aux file using \csname pointsofq@i\endcsname etc and \csname exam@numpoints\endcsname. Creating a table with a vaiaible number of rows or columns might be trickier. Commented Nov 11, 2021 at 15:00

2 Answers 2

2
+25

Why not use the built-in \gradetable command from the exam class.

\documentclass[a4paper,addpoints,11pt]{exam} 
\marksnotpoints
\vpword{Marks}
\hpword{Marks:}%<--
\begin{document}
\begin{coverpages}

\begin{center}
\gradetable[h][questions]%<--
\end{center}

\begin{center}
\gradetable[v][questions]%<--
\end{center}

\end{coverpages}
\begin{questions}
        \question[10]
        Example question
        \question[20]
        Example question
        \question[30]
        Example question
\end{questions}  
\end{document}

enter image description here

3
  • I know the existence of such an option; I would like to be able to customize the generation the way I want.
    – Diaa
    Commented Nov 16, 2021 at 17:04
  • @Diaa Do you want to format it? Commented Nov 19, 2021 at 22:15
  • 1
    @JasperHabicht if you are talking about the built-in one, then yes. However, I am not a TeXpert to manipulate things under the hood, so I wondered if I could create my own one using tabularray.
    – Diaa
    Commented Nov 19, 2021 at 22:33
1

This is as far as I got.

\documentclass[a4paper,addpoints,11pt]{exam} 

\marksnotpoints

\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}

\vqword{Question}
\vpword{Marks}

\begin{document}

    \begin{coverpages}
        
        
    \begin{tblr}
        [
        presep = 0pt, headsep = 0pt,
        footsep = 0pt, postsep = 0pt,
        ]{
            colsep = 1 em,
            column{1} = {0.15\linewidth},
            width = 0.5\linewidth,
            colspec = {
                X[ c, 2 ]
                X[ c, 1.5 ]
                X[ c, 1.5 ]
            },
            hline{2-Z} = {0.25pt},
            vlines = {0.25pt},
            rows = {m},
            row{1} = {10ex, font = \bfseries},
            row{2-Z} = {6ex, m},
            row{Z} = {font = \bfseries},
            rulesep = 0pt,
            rowsep = 0ex,
        }
        \toprule[1.5pt]
        Question & Marks & Score \\
        1\textsuperscript{st} & {\csname pointsofq@i\endcsname} & \\
        2\textsuperscript{nd} & {\csname pointsofq@ii\endcsname} & \\
        3\textsuperscript{rd} & {\csname pointsofq@iii\endcsname} & \\
        Total & {\csname exam@numpoints\endcsname} & \\
        \bottomrule[1.5pt]
    \end{tblr}
    
    \bigskip
    
    
    \begin{tblr}
        [
        presep = 0pt, headsep = 0pt,
        footsep = 0pt, postsep = 0pt,
        ]{
            colsep = 1 em,
            column{1} = {0.15\linewidth, font = \bfseries},
            column{Z} = {font = \bfseries},
            width = 0.75\linewidth,
            colspec = {
                X[ l, 2 ]
                *{3}{X[ c, 1.5 ]}
                X[ c, 2 ]
            },
            hline{2-Z} = {0.25pt},
            vlines = {0.25pt},
            rows = {6ex, m},
            rulesep = 0pt,
            rowsep = 0ex,
        }
        \toprule[1.5pt]
        Question & 1\textsuperscript{st} & 2\textsuperscript{nd} & 3\textsuperscript{rd} & Total \\
        Marks & {\csname pointsofq@i\endcsname} & {\csname pointsofq@ii\endcsname} & {\csname pointsofq@iii\endcsname} & {\csname exam@numpoints\endcsname}\\
        Score &  &  &  & \\
        \bottomrule[1.5pt]
    \end{tblr}

    \end{coverpages}
    
    
    
    \begin{questions}
        \question[10]
        Example question
        \question[20]
        Example question
        \question[30]
        Example question
    \end{questions}
    
\end{document} 
2
  • Is it possible to have a for loop over the total number of questions to robustly print a row for each question?
    – Diaa
    Commented Nov 16, 2021 at 16:37
  • I think a for loop over \numquestions is what remains to make your answer completely robust with a question counter to convert it to its ordinal.
    – Diaa
    Commented Nov 16, 2021 at 20:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .