I am trying to replicate the hand drawn table in latex.
So far what I have is the following code
\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\renewcommand{\thesection}{\arabic{section}}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{pgfplots}
\usepackage{amsmath}
\newtheorem{theorem}{THEOREM}
\newtheorem{proof}{PROOF}
\usepackage{tikz}
\usepackage{amssymb}
\usetikzlibrary{patterns}
\usepackage{fancyhdr}
\usepackage{bigints}
\usepackage{color}
\usepackage{tcolorbox}
\usepackage{color,xcolor}
\usepackage{booktabs,array}
\usepackage{hyperref}
\usepackage{graphicx}
\usetikzlibrary{arrows}
\usepackage{polynom}
\usepackage{flexisym}
\usepackage{wallpaper}
\usepackage{blkarray}
\usepackage{caption}
\usepackage{adjustbox}
\usepackage{multirow}
\usepgfplotslibrary{fillbetween}
\newenvironment{tightcenter}{
\setlength\topsep{0pt}
\setlength\parskip{0pt}
\begin{center}}{\end{center}}
\begin{document}
\begin{center}{
\setlength\arraycolsep{6pt} % default is "5pt"
$\begin{array}{lccc}
\midrule
\multirow{2}{*}{SECTION A} & \multicolumn{1}{l}{\begin{array}{@{}c@{}}\text{Number of}\\\text{questions}\end{array}} & \multicolumn{1}{l}{\begin{array}{@{}c@{}}\text{Number of questions}\\\text{to be answered}\end{array}} & \multicolumn{1}{l}{\begin{array}{@{}c@{}}\text{Number of}\\\text{marks}\end{array}}\\[0.224cm]
\hline
& \multicolumn{1}{c}{7} & \multicolumn{1}{c}{7} & \multicolumn{1}{c}{36} \\[0.224cm]
\hline
\text{SECTION B} & \begin{array}{@{}c@{}}\text{Number of}\\\text{questions}\end{array} & \begin{array}{@{}c@{}}\text{Number of questions}\\\text{to be answered}\end{array} & \begin{array}{@{}c@{}}\text{Number of}\\\text{marks}\end{array}\\[0.124cm]
\hline
& 4 & 2 & 24\\
\hline
& & & \text{Total }60\\
\hline
\end{array}$}
\end{center}
\end{document}
It seems to generate somewhat a similar table (as shown below), however the multi-row in the first column for Section A and Section B is not happening.
How do I achieve this? I also what to horizontally and vertically centre the texts in the table.
Thanks!
Best Answer
try
is this what you looking for?
as you can see, in above mwe (minimal working example) i remove from your code all what is not related to table. also i remove all not needed code complications as use
\multicolumn
for one column cells. observe, that insteadhline
are used rules frombooktabls
:\toprule
,\midrule
and\bottomrule
. for two line cells' content is used\makecell
from the\makecell
package.