Quero centralizar a linha vertical interna desenhada em tabela.
Código de exemplo:
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{|c|c|c|}
\hline
\multirow{2}{*}{R} & \multicolumn{2}{c|}{No. Jobs Completed/Submitted} \\ \cline{2-3}
& C1 & C2 \\ \hline
r1 & a & b \\ \hline
r2 & a & b \\ \hline
\end{tabular}
\end{document}
Sua saída:
Saída desejada: se possível, quero as colunas C1 e C2 divididas igualmente.
---------------------------------
|R |No. Jobs Completed/Submitted|
|r1| C1 | C2 |
|-------------------------------|
|r2| a | b |
--------------------------------
Responder1
Você pode usar o w
tipo -column do array
pacote:
\documentclass{article}
\usepackage{multirow,array}
\begin{document}
\setlength{\extrarowheight}{1pt}
\begin{tabular}{|c|w{c}{3cm}|w{c}{3cm}|}
\hline
\multirow{2}{*}{R} & \multicolumn{2}{c|}{No. Jobs Completed/Submitted} \\ \cline{2-3}
& C1 & C2 \\ \hline
r1 & a & b \\ \hline
r2 & a & b \\ \hline
\end{tabular}
\end{document}
PS: Recomenda-se usar o \extrarowheight
fornecido por array
para que a mesa fique melhor.
Responder2
Com o tabularray
pacote, você poderia usar a hspan=even
opção de distribuir as colunas uniformemente:
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{tblr}{
colspec={|c|c|c|},
hspan=even
}
\hline
\SetCell[r=2]{} R & \SetCell[c=2]{} No. Jobs Completed/Submitted & \\ \cline{2-3}
& C1 & C2 \\ \hline
r1 & a & b \\ \hline
r2 & a & b \\ \hline
\end{tblr}
\end{document}
Responder3
com bela matriz
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\begin{NiceTabular}[width=0.6\linewidth]{cX[c]X[c]}[hvlines,cell-space-limits=2pt]
\Block{2-1}{R} & \Block{1-2}{No. Jobs Completed/Submitted} & \\
& C1 & C2 \\
r1 & a & b \\
r2 & a & b \\
\end{NiceTabular}
\vspace{\baselineskip}
or
\vspace{\baselineskip}
\begin{NiceTabular}{c W{c}{3cm} W{c}{3cm}}[hvlines,cell-space-limits=2pt]
\Block{2-1}{R} & \Block{1-2}{No. Jobs Completed/Submitted} & \\
& C1 & C2 \\
r1 & a & b \\
r2 & a & b \\
\end{NiceTabular}
\end{document}
Responder4
O mesmo em espírito que oresposta de Estêvão, mas usando a largura natural do cabeçalho da sua tabela medindo-a:
\documentclass{article}
\usepackage{multirow, array}
\newlength\mylength
\begin{document}
\settowidth\mylength{No. Jobs Completed/Submitted}
\mylength=.5\dimexpr\mylength-\arrayrulewidth-2\tabcolsep\relax
\begin{tabular}{|c|*2{w{c}{\mylength}|}}
\hline
\multirow{2}{*}{R} & \multicolumn{2}{c|}{No. Jobs Completed/Submitted} \\ \cline{2-3}
& C1 & C2 \\ \hline
r1 & a & b \\ \hline
r2 & a & b \\ \hline
\end{tabular}
\end{document}
Uma versão embelezada da sua mesa, eliminando todas as regras verticais e usando booktabs
as horizontais:
\documentclass{article}
\usepackage{multirow, booktabs, array}
\newlength\mylength
\begin{document}
\settowidth\mylength{No. Jobs Completed/Submitted}
\mylength=.5\dimexpr\mylength-2\tabcolsep\relax
\begin{tabular}{c*2{w{c}{\mylength}}}
\toprule
\multirow{2}{*}{R} & \multicolumn{2}{c}{No. Jobs Completed/Submitted} \\
& C1 & C2 \\
\midrule
r1 & a & b \\
r2 & a & b \\
\bottomrule
\end{tabular}
\end{document}