3

Problem

I'm trying to recreate the following table:

VCAA Exam marking distribution

I have pretty much achieved this, but the last column is stuffing me up as I can't get the numbers centered with the text showing to the left of the 80 in the last row. I've tried a myriad of options from the siunitx package documentation, but none of them give me a favourable result. Below is what I have so far.

TL;DR: I want to have the last column of the table center the numbers without any consideration for the text (i.e., "Total "), which should be placed before the number in the last row.

MWE

Code

\documentclass[11pt]{exam}

\usepackage{amsmath}

\usepackage{newtxtext, newtxmath}

\usepackage{tabularray}
\UseTblrLibrary{siunitx}

\usepackage{float}

\begin{document}

\begin{table}[H]
    \centering
    \begin{tblr}{
                    colspec={
                                X[c,m,0.75] *{2}{X[c,m,si={table-format=2}]} X[c,m,si={
                                                                                        table-format=2,
                                                                                        table-align-text-before=false,
                                                                                        table-number-alignment=left,
                                                                                        table-text-alignment=center,
                                                                                        table-alignment-mode=marker
                                                                                       }]},
                    row{1}={guard, font=\itshape, preto={\fontsize{9}{10.8}\selectfont}},
                    width=129mm,
                    hline{1,Z}={0.36mm},
                    vline{1,Z}={0.36mm},
                    hline{2}={0.18mm},
                    row{1}={9mm,t},
                    row{2-Z}={5.03mm,f}
                }
        Section    &    {Number of\\questions} &    {Number of questions\\to be answered} &    {Number of\\marks} \\
        A          &    20                     &    20                                    &                20     \\
        B          &     5                     &     5                                    &                60     \\
                   &                           &                                          &    Total~ 80
    \end{tblr}
\end{table}

\end{document}

Image

My attempt at recreating the table

5
  • Off topic, from a visual point of view I don’t think that mixed style is a good idea.
    – MS-SPO
    Nov 5, 2023 at 1:57
  • Welp, I'm trying to replicate the exact style of VCAA exams :) Nov 5, 2023 at 2:09
  • 1
    As I see the obtained table doesn't differ from desired result. What than is a problem?
    – Zarko
    Nov 5, 2023 at 2:39
  • @Zarko Thank you for your answer as well, but the problem is that the last column's numbers aren't centered. I guess what I'm trying to say is that the numbers in the last column should be centered, but the centering shouldn't take into account the "Total " text. My bad, I'll edit my question to better reflect the problem. Nov 5, 2023 at 3:23
  • 1
    BrightBulb123, you are right. Sorry, I didn't load last version of my MWE and resulted image. Now should be as you like to have (hopefully).
    – Zarko
    Nov 5, 2023 at 4:03

1 Answer 1

5

To me the showed desired result and obtained by your code are almost identical, so it is not clear, what is your problem. SO I only a wee bit make your code smore consistent and shorter:

\documentclass[11pt]{exam}
\usepackage{newtxtext, newtxmath}

\usepackage{tabularray}
\UseTblrLibrary{amsmath, siunitx}  % <---

%\usepackage{float}

\begin{document}
    \begin{table}[htb]%[H]
    \centering
\begin{tblr}{width=129mm,
             colspec = {     X[c]
                        *{3}{X[c,si={table-format=2.0}]} % <---
                        },
             row{1}={guard, font={\itshape\fontsize{9}{10.8}\selectfont}},
             hline{1,Z}={0.36mm},   
             hline{2,Y}={0.18mm},% remove option Y if you don't like to have this line
             vline{1,Z}={0.36mm},
                }
Section &   {Number of\\ questions}    
                &   {Number of questions\\ to be answered}
                        &   {Number of\\ marks}         \\
A       &   20  &   20  &   20                          \\
B       &     5 &    5  &   60                          \\
        &       &       &   \rlap{Total}80              \\  % <--- or \rlap{~ Total}80 or \rlap{qquad Total}80 or ...
\end{tblr}
    \end{table}
\end{document}

image of table

I add vertical lines for better visibility that numbers are centered. In real document ju just remove table options vlines.

3
  • Thanks for the solution! I've marked this the answer for now, but is there a way to get the text to fit more cleanly so it looks like it's been typed as one line and avoid the awkward space between the "Total" and "80"? Nov 5, 2023 at 6:09
  • @BrightBulb123, what you men for now? If answer not fulfil your expectation, than don't accept it. Anyway, answer gives clear way how to manages the problem. Its tuning is up to you (you can insert ~ before word "Total": \rlap{~ Total} or insert different lenght instead it). Sorry, after your comment I will mark your question as "unclear".
    – Zarko
    Nov 5, 2023 at 9:36
  • Don't worry about it, I got what I wanted by just using \hspace{...} before the word "Total" (the exact spacing I used was \hspace{1.4em - 3.19374pt}, which is based on approximations + the width of a "space" character in my current font). This makes it replicate the original picture more. Again, thank you for your answer. Nov 5, 2023 at 9:37

You must log in to answer this question.

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