Search code examples
latexcelltabular

LaTeX - full width row on a tabular - cell occupying multiple cells


I am trying to recreate this table on Latex: https://i.sstatic.net/b6QOv.png but I can't figure out how to have a cell occupying three cells instead of just one (for the Tritanomaly percentage entry for example).

This is the best that I've been able to do so far:

\usepackage{slashbox}
\usepackage[table]{xcolor}

\begin{document}

\begin{table}[h]
\centering
{\rowcolors{2}{gray!15}{gray!0}
\begin{tabular}{|l||c|c|c|}
\hline
\backslashbox{CVD}{Sex}
&Male&Female&\textbf{Any}\\\hline\hline
Deuteranomaly & 5\% & 0.35\% & 2.68\% \\\hline
Deuteranopia & 1\% & 0.1\% & 0.56\% \\\hline
Protanomaly & 1.08\% & 0.03\% & 0.55\% \\\hline
Protanopia & 1.01\% & 0.01\% & 0.51\% \\\hline
Tritanomaly* &&  0.02\% & \\ \hline
Tritanopia* && 0.01\% &\\\hline
Monochromacy* && 0.0001\% &\\\hline
\textbf{Total} & \textbf{8.12}\% & \textbf{0.52}\% & \textbf{4.32}\% \\\hline
\end{tabular}
\end{table}

\end{document}

Thank you in advance


Solution

  • \multicolumn is your new best friend:

    \documentclass{article}
    
    \usepackage{slashbox}
    \usepackage[table]{xcolor}
    
    \begin{document}
    
    \begin{table}[h]
    \centering
    \rowcolors{2}{gray!15}{gray!0}
    \begin{tabular}{|l||c|c|c|}
    \hline
    \backslashbox{CVD}{Sex}
    &Male&Female&\textbf{Any}\\\hline\hline
    Deuteranomaly & 5\% & 0.35\% & 2.68\% \\\hline
    Deuteranopia & 1\% & 0.1\% & 0.56\% \\\hline
    Protanomaly & 1.08\% & 0.03\% & 0.55\% \\\hline
    Protanopia & 1.01\% & 0.01\% & 0.51\% \\\hline
    Tritanomaly* & \multicolumn{3}{c|}{0.02\%} \\ \hline
    Tritanopia* &\multicolumn{3}{c|}{0.02\%}\\\hline
    Monochromacy* &\multicolumn{3}{c|}{0.02\%}\\\hline
    \textbf{Total} & \textbf{8.12}\% & \textbf{0.52}\% & \textbf{4.32}\% \\\hline
    \end{tabular}
    \end{table}
    
    \end{document}
    

    enter image description here