Help to tabular. How to set different sizes of cell in tabular enviroment?
With the help of the tabularx
package you can ensure that the table is as wide as the textwidth. I have declared a new, centered column type for this. With xcolor
and the table
option the rowcolor
and columncolor
commands can be used. With >{\hsize=1.5\hsize}
you can change the width of the C
type columns. (Make sure that the sum of the values is equal to the number of C
type columns used (e.g. 1.5+1.5+0.75+0.25=4 for 4 columns).
Lastly, I'd not recommend using the lines from the booktabs
package in combination with vertical lines (as you did in your MWE). You might have noticed the small gaps in the vertical lines that are due to the fact that the booktabs lines are designed to be used in tables without vertical lines.
\documentclass[a4paper,12pt]{report}
\usepackage{geometry}
\usepackage{multirow}
\usepackage[table]{xcolor}
\usepackage{tabularx}
\usepackage{ragged2e}
\usepackage{hhline}
\newcolumntype{C}{>{\Centering}X}
\begin{document}\noindent
\begin{tabularx}{\textwidth}{|>{\columncolor{lightgray}}c
|>{\hsize=1.5\hsize}C
|>{\hsize=1.5\hsize}C
|>{\hsize=.75\hsize}C
|>{\hsize=.25\hsize}C
|c|c|}
\hline
\rowcolor{lightgray}
& & & & & \multicolumn{2}{c|}{Scores}\\ \hhline{*5{>{\arrayrulecolor{lightgray}}-}*{2}{>{\arrayrulecolor{black}}-}}
\rowcolor{lightgray}
\multirow{-2.2}{*}{Question} & \multirow{-2.2}{*}{a)} & \multirow{-2.2}{*}{b)} & \multirow{-2.2}{*}{c)} & \multirow{-2.2}{*}{d)} & Individual & Team \\
\hline
1. & & & & & & \\
\hline
2. & & & & & & \\
\hline
\rowcolor{lightgray}
\multicolumn{5}{|c|}{TOTAL} & & \\
\hline
\end{tabularx}
\end{document}
If you wish to stick to the booktabs
lines, I'd suggest a layout without vertical lines, with fewer horizontal lines and without color:
\documentclass[a4paper,12pt]{report}
\usepackage{geometry}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{ragged2e}
\newcolumntype{C}{>{\Centering}X}
\usepackage{booktabs}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{lCCCCcc}
\toprule
& & & & & \multicolumn{2}{c}{Scores}\\ \cmidrule{6-7}
\multirow{-2.2}{*}{Question} & \multirow{-2.2}{*}{a)} & \multirow{-2.2}{*}{b)} & \multirow{-2.2}{*}{c)} & \multirow{-2.2}{*}{d)} & Individual & Team \\
\midrule
1. & & & & & & \\
2. & & & & & & \\
\cmidrule{1-5}
\multicolumn{5}{l}{TOTAL} & & \\
\bottomrule
\end{tabularx}
\end{document}
Use tabularx
package:
\documentclass[a4paper,brazil, 12pt]{report}
\usepackage{tikz}
\usepackage{geometry}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{float}
\usepackage{adjustbox}
\geometry{a4paper,
top=1.5cm,
bottom=1.5cm,
left=1.5cm,
right=1.5cm,
}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{\linewidth}{|X|X|X|X|X|X|X|}
\hline
\multirow{2}{*}{{Question}} & \multirow{2}{*}{a} & \multirow{2}{*}{b} & \multirow{2}{*}{c} & \multirow{2}{*}{d} & \multicolumn{2}{c|}{Scores} \\
\cmidrule{6-7}
& & & & & Individual & Team \\
\midrule
1 & & & & & & \\
\midrule
2 & & & & & & \\
\midrule
3 & & & & & & \\
\midrule
4 & & & & & & \\
\midrule
5 & & & & & & \\
\midrule
6 & & & & & & \\
\midrule
7 & & & & & & \\
\midrule
8 & & & & & & \\
\midrule
9 & & & & & & \\
\midrule
10 & & & & & & \\
\midrule
\multicolumn{5}{|c|}{Total} & & \\
\bottomrule
\end{tabularx}
\end{document}
1. Requested layout
If you want to try a different solution, in particular if you build a class or template, here is a solution using cals:
\documentclass[a4paper,12pt]{report}
\usepackage[margin=1.5cm]{geometry}
\usepackage[table]{xcolor}
\usepackage{cals, calc}
\newlength{\bcw}
\thispagestyle{empty}
% Shortcuts
\let\nc=\nullcell
\let\sc=\spancontent
\begin{document}
\setlength{\bcw}{((\columnwidth / 30))} % basic column width is half the width of narrowest column
\noindent\rule{\columnwidth}{2pt}\smallskip % checking that the tabular do not extend into the margin
\begin{calstable}
\makeatletter
\colwidths{{3.5\bcw}{5.5\bcw}{5.5\bcw}{4\bcw}{3.5\bcw}{5.5\bcw}{2.5\bcw}{0pt}} % Sum should be 30
\def\cals@framers@width{0.4pt}
\def\cals@framecs@width{0.4pt}
%
\brow
\def\cals@bgcolor{lightgray} % Color command is in effect until reset
\nc{lrt}
\nc{lrt}
\nc{lrt}
\nc{lrt}
\nc{lrt}
\nc{ltb}
\nc{rtb}\alignC\sc{\textbf{Scores}}
\cell{}
\erow
%
\brow
\nc{lrb}\alignC\sc{\vfil \textbf{Question}} % Alignment command works until reset by a `\alignL` or `\alignR`
\nc{lrb}\sc{\vfil a)}
\nc{lrb}\sc{\vfil b)}
\nc{lrb}\sc{\vfil c)}
\nc{lrb}\sc{\vfil d)}
\cell{Individual}
\cell{Team}
\cell{}
\erow
%
\brow
\cell{1.}
\def\cals@bgcolor{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\erow
%
\brow
\def\cals@bgcolor{lightgray}
\cell{2.}
\def\cals@bgcolor{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\erow
%
\brow
\def\cals@bgcolor{lightgray}
\cell{3.}
\def\cals@bgcolor{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\erow
%
\brow
\def\cals@bgcolor{lightgray}
\cell{4.}
\def\cals@bgcolor{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\erow
%
\brow
\def\cals@bgcolor{lightgray}
\cell{5.}
\def\cals@bgcolor{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\erow
%
\brow
\def\cals@bgcolor{lightgray}
\cell{6.}
\def\cals@bgcolor{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\erow
%
\brow
\def\cals@bgcolor{lightgray}
\cell{7.}
\def\cals@bgcolor{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\erow
%
\brow
\def\cals@bgcolor{lightgray}
\cell{8.}
\def\cals@bgcolor{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\erow
%
\brow
\def\cals@bgcolor{lightgray}
\cell{9.}
\def\cals@bgcolor{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\erow
%
\brow
\def\cals@bgcolor{lightgray}
\cell{10.}
\def\cals@bgcolor{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\erow
%
\brow
\def\cals@bgcolor{lightgray}
\nc{ltb}
\nc{tb}
\nc{tb}
\nc{tb}
\nc{rtb}\alignR\sc{\textbf{TOTAL}}
\cell{}
\cell{}
\cell{}
\def\cals@bgcolor{}
\erow
\makeatother
\end{calstable}
\end{document}
2.‘booktabs’ version
Here is my attempt to code a ‘booktabs’-version of the tabular:
\documentclass[a4paper,12pt]{report}
\usepackage[margin=1.5cm]{geometry}
\usepackage{cals, calc}
\newlength{\bcw}
\thispagestyle{empty}
% Shortcuts
\let\nc=\nullcell
\let\sc=\spancontent
\begin{document}
\setlength{\bcw}{((\columnwidth / 30))} % basic column width is half the width of narrowest column
\noindent\rule{\columnwidth}{2pt}\bigskip % checking that the tabular do not extend into the margin
\begin{calstable}
\colwidths{{1.25\bcw}{2.75\bcw}{5\bcw}{5\bcw}{4\bcw}{4\bcw}{5\bcw}{3\bcw}} % Sum should be 30
\makeatletter
\def\cals@framers@width{0.8pt}
\def\cals@framecs@width{0pt}
\cals@setpadding{Ag}
\cals@setcellprevdepth{Al}
\def\cals@cs@width{0pt}
\def\cals@rs@width{0.4pt}
%
\setlength\cals@paddingR{0pt}
\thead{\bfseries\selectfont%
\brow
\setlength\cals@paddingL{0pt}
\nc{lt}
\cals@setpadding{Ag}
\nc{rt}
\nc{lrt}
\nc{lrt}
\nc{lrt}
\nc{lrt}
\nc{ltb}
\setlength\cals@paddingR{0pt}
\nc{rtb}\alignC\sc{Scores}
\cals@setpadding{Ag}
\erow
%
\brow
\setlength\cals@paddingL{0pt}
\nc{lb}
\cals@setpadding{Ag}
\nc{rb}\alignL\sc{\vfil Question} % Alignment command works until reset by a `\alignL` or `\alignR`
\nc{lrb}\alignC\sc{\vfil a)}
\nc{lrb}\sc{\vfil b)}
\nc{lrb}\sc{\vfil c)}
\nc{lrb}\sc{\vfil d)}
\cell{Individual}
\setlength\cals@paddingR{0pt}
\cell{Team}
\cals@setpadding{Ag}
\erow
\mdseries}
%
\brow
\setlength\cals@paddingL{0pt}
\alignR\cell{1.}
\cals@setpadding{Ag}
\cell{}
\alignC\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\setlength\cals@paddingR{0pt}
\cell{}
\cals@setpadding{Ag}
\erow
%
\brow
\def\cals@rs@width{0pt}
\setlength\cals@paddingL{0pt}
\alignR\cell{2.}
\cals@setpadding{Ag}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\setlength\cals@paddingR{0pt}
\cell{}
\cals@setpadding{Ag}
\erow
%
\brow
\setlength\cals@paddingL{0pt}
\alignR\cell{3.}
\cals@setpadding{Ag}
\cell{}
\alignC\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\setlength\cals@paddingR{0pt}
\cell{}
\cals@setpadding{Ag}
\erow
%
\brow
\setlength\cals@paddingL{0pt}
\alignR\cell{4.}
\cals@setpadding{Ag}
\cell{}
\alignC\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\setlength\cals@paddingR{0pt}
\cell{}
\cals@setpadding{Ag}
\erow
%
\brow
\setlength\cals@paddingL{0pt}
\alignR\cell{5.}
\cals@setpadding{Ag}
\cell{}
\alignC\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\setlength\cals@paddingR{0pt}
\cell{}
\cals@setpadding{Ag}
\erow
%
\brow
\setlength\cals@paddingL{0pt}
\alignR\cell{6.}
\cals@setpadding{Ag}
\cell{}
\alignC\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\setlength\cals@paddingR{0pt}
\cell{}
\cals@setpadding{Ag}
\erow
%
\brow
\setlength\cals@paddingL{0pt}
\alignR\cell{7.}
\cals@setpadding{Ag}
\cell{}
\alignC\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\setlength\cals@paddingR{0pt}
\cell{}
\cals@setpadding{Ag}
\erow
%
\brow
\setlength\cals@paddingL{0pt}
\alignR\cell{8.}
\cals@setpadding{Ag}
\cell{}
\alignC\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\setlength\cals@paddingR{0pt}
\cell{}
\cals@setpadding{Ag}
\erow
%
\brow
\setlength\cals@paddingL{0pt}
\alignR\cell{9.}
\cals@setpadding{Ag}
\cell{}
\alignC\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\setlength\cals@paddingR{0pt}
\cell{}
\cals@setpadding{Ag}
\erow
%
\brow
\setlength\cals@paddingL{0pt}
\alignR\cell{10.}
\cals@setpadding{Ag}
\cell{}
\alignC\cell{}
\cell{}
\cell{}
\cell{}
\cell{}
\setlength\cals@paddingR{0pt}
\cell{}
\cals@setpadding{Ag}
\erow
%
\brow
\setlength\cals@paddingL{0pt}
\nc{ltb}
\nc{tb}
\nc{tb}
\nc{tb}
\nc{tb}
\nc{rtb}\alignL\sc{\textbf{TOTAL}}
\cals@setpadding{Ag}
\cell{}
\setlength\cals@paddingR{0pt}
\cell{}
\cals@setpadding{Ag}
\def\cals@rs@width{0.4pt}
\erow\makeatother
\end{calstable}
\end{document}
Here is the result: