0

How can I create the following table?

enter image description here

3
  • 2
    Welcome to TeX.SX! You should be able to create this table by looking around on this site for similar peojects. You can also try Google. There are different approaches for typesetting such tables. It would be best if you could come up with a minimal working example (MWE) that shows what you tried so far and where exactly you got stuck. This site is not exactly a manual for everything, so you should probably first familiarize yourself with how to typeset tables in general. Nov 7, 2023 at 15:59
  • Start with a tabular with 9 columns and use \multicolumn{3}{c}{Part 3} and similar for Part 4 and also for the foot.
    – cabohah
    Nov 7, 2023 at 16:05
  • Should the "Part 1" and "Part 2" column groups have the same widths as the "Part 3" and "Part 4" column groups?
    – Mico
    Nov 7, 2023 at 16:26

4 Answers 4

2

Edit: After taking into account the comments from @Mico, I realised that there is no need to use the multirow package and any commands associated with it. The following code still produces the desired output:

\documentclass{report}

\begin{document}
    \begin{table}[]
        \begin{tabular}{|c|c|ccc|ccc|c|}
            \hline
            \multicolumn{1}{|l|}{Part 1} & \multicolumn{1}{l|}{Part 2} & \multicolumn{3}{c|}{Part   3}                                                                               & \multicolumn{3}{c|}{Part   4}                                                                               & \multicolumn{1}{l|}{Sum}   \\ \hline
                       &           & \multicolumn{1}{l|}{Q1}                & \multicolumn{1}{l|}{Q2}                & \multicolumn{1}{l|}{Q3}   & \multicolumn{1}{l|}{Q1}                & \multicolumn{1}{l|}{Q2}                & \multicolumn{1}{l|}{Q3}   &        \\ \cline{3-8}
            &                             & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} &          & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} &         &                            \\
            &                             & \multicolumn{1}{c|}{}                  & \multicolumn{1}{c|}{}                  &                           & \multicolumn{1}{c|}{}                  & \multicolumn{1}{c|}{}                  &                           &                            \\
            &                             & \multicolumn{1}{c|}{}                  & \multicolumn{1}{c|}{}                  &                           & \multicolumn{1}{c|}{}                  & \multicolumn{1}{c|}{}                  &                           &                            \\
            &                             & \multicolumn{1}{c|}{}                  & \multicolumn{1}{c|}{}                  &                           & \multicolumn{1}{c|}{}                  & \multicolumn{1}{c|}{}                  &                           &                            \\
            &                             & \multicolumn{1}{c|}{}                  & \multicolumn{1}{c|}{}                  &                           & \multicolumn{1}{c|}{}                  & \multicolumn{1}{c|}{}                  &                           &                            \\
            &                             & \multicolumn{1}{c|}{}                  & \multicolumn{1}{c|}{}                  &                           & \multicolumn{1}{c|}{}                  & \multicolumn{1}{c|}{}                  &                           &                            \\
            &                             & \multicolumn{1}{c|}{}                  & \multicolumn{1}{c|}{}                  &                           & \multicolumn{1}{c|}{}                  & \multicolumn{1}{c|}{}                  &                           &                            \\
            &                             & \multicolumn{1}{c|}{}                  & \multicolumn{1}{c|}{}                  &                           & \multicolumn{1}{c|}{}                  & \multicolumn{1}{c|}{}                  &                           &                            \\ \cline{3-8}
            &                             & \multicolumn{1}{l|}{5pts}              & \multicolumn{1}{l|}{5pts}              & \multicolumn{1}{l|}{5pts} & \multicolumn{1}{l|}{5pts}              & \multicolumn{1}{l|}{5pts}              & \multicolumn{1}{l|}{5pts} &                            \\ \hline
            \multicolumn{1}{|l|}{30pts}  & \multicolumn{1}{l|}{20pts}  & \multicolumn{3}{c|}{15pts}                                                                                  & \multicolumn{3}{c|}{15pts}                                                                                  & \multicolumn{1}{l|}{80pts} \\ \hline
        \end{tabular}
    \end{table}
\end{document}

Below is the output as it is appearing in the sketch diagram posted by @DSPinfinity:
enter image description here

6
  • 2
    Packagemultirow not multicol. BTW: You wouldn't need so many \multicolumn{1}{c|}, if you'd add the | to the column specification of the tabular.
    – cabohah
    Nov 7, 2023 at 16:13
  • 1
    What's the purpose of \multirow{10}{*}{} and \multicolumn{1}{c|}{\multirow{8}{*}{}}?
    – Mico
    Nov 7, 2023 at 16:25
  • The purpose of \multirow{10}{*}{} and \multicolumn{1}{c|}{\multirow{8}{*}{}} is of increasing the white space e.g the white space between the labelling Part 1 and 30 pts is 10 rows while the whitespace between the labelling Q1 and 5pts is 8 rows in length.
    – itc
    Nov 7, 2023 at 16:33
  • 2
    Hint: Remove all \multirow directives and check if the output is different.
    – Mico
    Nov 7, 2023 at 16:42
  • Thanks @Mico. I greatly appreciate your comment.
    – itc
    Nov 7, 2023 at 16:53
3

With {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\color{red}
\begin{NiceTabular}{*9{c}}[hvlines]
  Part 1 & Part 2  & \Block{1-3}{Part 3} &&& \Block{1-3}{Part 4} &&& Sum  \\
  \Block{3-1}{} & \Block{3-1}{} & 01 & 02 & 03 & 01 & 02 & 03 & \Block{3-1}{} \\
                                                                          \\[3cm]
         & & 5\,pts & 5\,pts & 5\,pts & 5\,pts & 5\,pts & 5\,pts \\
  30\,pts & 20\,pts & \Block{1-3}{15\,pts}&&& \Block{1-3}{15\,pts} &&& 80\,pts \\
\end{NiceTabular}
\end{document}

You need several compilations.

Output of the above code

2

Here an example with the tabular features of the LaTeX kernel only:

\documentclass{article}
\usepackage{color}
\begin{document}
\color{red}
\begin{tabular}{|*9{c|}}
  \hline
  Part 1 & Part 2  & \multicolumn{3}{c|}{Part 3} & \multicolumn{3}{c|}{Part 4} & Sum \\
  \hline
         & & 01 & 02 & 03 & 01 & 02 & 03 & \\
  \cline{3-8}
         & & & & & & & & \\
         & & & & & & & & \\
         & & & & & & & & \\
         & & & & & & & & \\
         & & & & & & & & \\
         & & & & & & & & \\
  \cline{3-8}
         & & 5\,pts & 5\,pts & 5\,pts & 5\,pts & 5\,pts & 5\,pts & \\
  \hline
  30\,pts & 20\,pts & \multicolumn{3}{c|}{15\,pts}& \multicolumn{3}{c|}{15\,pts} & 80\,pts \\
  \hline
\end{tabular}
\end{document}

enter image description here

But as an alternative, you could use, e.g., package tabularx, tabularray, hhline and a lot of other packages. You could even make if more fancy using packages like xcolor and colortbl or TikZ or …

2

The OP didn't state this explicitly, but I will assume that they want the five header cells -- "Part 1" thru "Sum" -- to have equal widths. To achieve this objective, I suggest (a) setting up a 5*3=15-column tabularx environment, (b) setting the table's target width to \textwidth, and (c) using \multicolumn{3} directives to typeset the contents of the combined cells in the first and last row.

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage{tabularx}   % for 'tabularx' env. and 'X' column type
\usepackage{ragged2e}   % for '\Centering' macro
\newcolumntype{C}{>{\Centering}X} % centered version of 'X' column type

\begin{document}
\noindent
\setlength\tabcolsep{1pt}% default: 6pt
\setlength\extrarowheight{2pt}% % optional, for a more open "look"
\begin{tabularx}{\textwidth}{| *{3}{C} | *{3}{C} | *{6}{C|} *{3}{C} |}
\hline
\multicolumn{3}{|c|}{Part 1} &
\multicolumn{3}{ c|}{Part 2} &
\multicolumn{3}{ c|}{Part 3} &
\multicolumn{3}{ c|}{Part 4} &
\multicolumn{3}{ c|}{Sum} \\
\hline
& & & & & & 01 & 02 & 03 & 01 & 02 & 03 & & & \\
\cline{7-12}
& & & & & & & & & & & & & &\\ % fill in the blanks...
& & & & & & & & & & & & & &\\
& & & & & & & & & & & & & &\\
& & & & & & & & & & & & & &\\
& & & & & & & & & & & & & &\\
& & & & & & & & & & & & & &\\
\cline{7-12}
& & & & & & 5\,pts & 5\,pts & 5\,pts & 5\,pts & 5\,pts & 5\,pts & & & \\
\hline
\multicolumn{3}{|c|}{30\,pts} &
\multicolumn{3}{ c|}{20\,pts} &
\multicolumn{3}{ c|}{15\,pts} &
\multicolumn{3}{ c|}{15\,pts} &
\multicolumn{3}{ c|}{80\,pts} \\
\hline
\end{tabularx}

\end{document}

You must log in to answer this question.

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