1

I'm attempting to recreate this table in Latex:

enter image description here

My code so far is:

\documentclass{article}

\usepackage{multirow}
\usepackage{multicol}

\begin{document}

\begin{table}[h!]
  \centering
  \begin{tabular}{c|cc|cc|cc|cc}
     & \textbf{1} & \textbf{2} & \textbf{3} & \textbf{4} & \textbf{5} & \textbf{6} & \textbf{7} & \textbf{8}\\\hline
    \textbf{A} & \multicolumn{2}{c}{\multirow{8}{*}{a}} & 
    \multicolumn{2}{c}{\multirow{4}{*}{b}} & 
    \multicolumn{2}{c}{\multirow{4}{*}{d}} & 
    \multicolumn{2}{c}{\multirow{4}{*}{f}}\\
    \textbf{B} & & & & & & &\\
    \textbf{C} & & & & & & &\\
    \textbf{D} & & & & & & &\\\cline{4-9}
    \textbf{E} & & &
    \multicolumn{2}{c}{\multirow{4}{*}{c}} & 
    \multicolumn{2}{c}{\multirow{4}{*}{e}} & 
    \multicolumn{2}{c}{\multirow{4}{*}{g}}\\
    \textbf{F} & & & & & & &\\
    \textbf{G} & & & & & & &\\
    \textbf{H} & & & & & & &\\
  \end{tabular}
\end{table}
\end{document}

The output of which is:

enter image description here

However, the vertical lines break 2nd and 6th rows, which I cannot fix.

How do I make the vertical lines pass through all the cells?

  • 2
    Change c to |c| in your \multicolumns. – schtandard Jun 9 '19 at 9:55
3

Add a single | to the relevant \multicolumn preambles:

\documentclass{article}

\usepackage{multirow}
\usepackage{multicol}

\begin{document}

\begin{table}[h!]
  \centering
  \begin{tabular}{c|cc|cc|cc|cc}
     & \textbf{1} & \textbf{2} & \textbf{3} & \textbf{4} & \textbf{5} & \textbf{6} & \textbf{7} & \textbf{8}\\\hline
    \textbf{A} & \multicolumn{2}{c|}{\multirow{8}{*}{a}} &
    \multicolumn{2}{c|}{\multirow{4}{*}{b}} &
    \multicolumn{2}{c|}{\multirow{4}{*}{d}} &
    \multicolumn{2}{c}{\multirow{4}{*}{f}}\\
    \textbf{B} & & & & & & &\\
    \textbf{C} & & & & & & &\\
    \textbf{D} & & & & & & &\\\cline{4-9}
    \textbf{E} & & &
    \multicolumn{2}{c|}{\multirow{4}{*}{c}} &
    \multicolumn{2}{c|}{\multirow{4}{*}{e}} &
    \multicolumn{2}{c}{\multirow{4}{*}{g}}\\
    \textbf{F} & & & & & & &\\
    \textbf{G} & & & & & & &\\
    \textbf{H} & & & & & & &\\
  \end{tabular}
\end{table}

\end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.