0

I'm trying to make a table with multiple multicolumn and tabularx. It seems like I've a hidden column somewhere that I can't get rid of. This is the minimal reproducible example:

\documentclass{article}
\usepackage[margin=0.7in]{geometry}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{float}
\usepackage{amsmath}
\usepackage{tabularx}
\newcolumntype{C}{>{\Centering\arraybackslash}X} % centered "X" column
\usepackage[table,xcdraw]{xcolor}
\usepackage{multirow}

\date{December 2020}
\title{test}
\begin{document}

\maketitle



\begin{table}[H]
\caption{table caption}
\setlength\extrarowheight{2pt} % for a bit of visual "breathing space"
\begin{tabularx}{\textwidth}{|C|C|C|C|C|C|}
    \hline
    \multicolumn{6}{c}{\cellcolor[HTML]{9B9B9B}\textbf{Business consequences of a prolonged outage of the system (worst case)}}\\
    
    \rowcolor[HTML]{C0C0C0} 
    \textbf{Ref} & \textbf{Question} & \multicolumn{3}{c}{\textbf{Impact (circle the answer)}} & \textbf{Motivation}\\
    \hline
    
     A01 & Lorem ipsum dolor sit amet, consectetur adipiscing elit? & <2 hours & <1 day & >1day & xx \\ \hline
     
     A02 & Lorem ipsum dolor sit amet, consectetur adipiscing elit? & yes & yes, but not directly available & No &  xx \\ \hline
     
     A03 & Lorem ipsum dolor sit amet, consectetur adipiscing elit? & <100 & <1000 & >1000 &  xx \\ \hline
     
     A04 & Lorem ipsum dolor sit amet, consectetur adipiscing elit? & yes & No, entire Radboud University & No, entire Radboud University and external parties & xx \\ \hline
     A05 & Lorem ipsum dolor sit amet, consectetur adipiscing elit? & yes (fast) & Yes, there is a backup & No all data is lost &  xx \\ \hline
     
     \rowcolor[HTML]{C0C0C0} 
     \multicolumn{2}{c}{\cellcolor[HTML]{C0C0C0}} & \textbf{Low} & \textbf{Medium} & \textbf{High} & \cellcolor[HTML]{C0C0C0} \\ \cline{3-5}
     
     \multicolumn{2}{c}{\multirow{-2}{*}{\cellcolor[HTML]{C0C0C0}Result (check one of the three boxes below)}} &  &  &  & \multirow{-2}{*}{\cellcolor[HTML]{C0C0C0}} \\ \hline
\end{tabularx}
\label{table:Business consequences}
\end{table}


\end{document}

And this is the output:

enter image description here

I can't understand why it seems like that column is split in half nor why there is an ugly horizontal spacing between some words

6
  • after an error don't even look at the pdf output, tex's error recovery does not try to make sensible typesetting, just recover enough to syntax check the remaining document. ! Undefined control sequence. <template> ...tartpbox {\TX@col@width }\Centering You need to define \Centering Dec 9, 2020 at 16:20
  • column 2 is forced wide by your result entry which is long and not allowing line breaking. Dec 9, 2020 at 16:24
  • @DavidCarlisle oeeh i must've missed that error, I grabbed that line from the internet because without the C my table kept over floating outside the page and that seemed to have helped.
    – user230633
    Dec 9, 2020 at 16:24
  • How could i allow line breaking?
    – user230633
    Dec 9, 2020 at 16:25
  • well first add \author{zzz} to avoid the error in maketitle, and add \usepackage{ragged2e} to define \Centering then I would get rid of \multirow and use p{3cm} or whatever width you need or use a less extravagant wording so it doesn't need linebreaking Dec 9, 2020 at 16:27

1 Answer 1

0

The over long result text was forcing the column to be over-wide. You could use a p column there but after the text wraps it is not above the boxes anymore so needs re-wording anyway so it is simpler to just use two entries and get rid of multirow. Also don't forget to re-insert the vertical rules when you have \multicolumn

enter image description here

\documentclass{article}
\usepackage[margin=0.7in]{geometry}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{float,ragged2e}
\usepackage{amsmath}
\usepackage{tabularx}
\newcolumntype{C}{>{\Centering\arraybackslash}X} % centered "X" column
\usepackage[table,xcdraw]{xcolor}
\usepackage{multirow}

\date{December 2020}
\author{zzz}
\title{test}
\begin{document}

\maketitle



\begin{table}[H]
\caption{table caption}
\setlength\extrarowheight{2pt} % for a bit of visual "breathing space"
\begin{tabularx}{\textwidth}{|C|C|C|C|C|C|}
    \hline
    \multicolumn{6}{|c|}{\cellcolor[HTML]{9B9B9B}\textbf{Business consequences of a prolonged outage of the system (worst case)}}\\
    
    \rowcolor[HTML]{C0C0C0} 
    \textbf{Ref} & \textbf{Question} & \multicolumn{3}{c|}{\textbf{Impact (circle the answer)}} & \textbf{Motivation}\\
    \hline
    
     A01 & Lorem ipsum dolor sit amet, consectetur adipiscing elit? & <2 hours & <1 day & >1day & xx \\ \hline
     
     A02 & Lorem ipsum dolor sit amet, consectetur adipiscing elit? & yes & yes, but not directly available & No &  xx \\ \hline
     
     A03 & Lorem ipsum dolor sit amet, consectetur adipiscing elit? & <100 & <1000 & >1000 &  xx \\ \hline
     
     A04 & Lorem ipsum dolor sit amet, consectetur adipiscing elit? & yes & No, entire Radboud University & No, entire Radboud University and external parties & xx \\ \hline
     A05 & Lorem ipsum dolor sit amet, consectetur adipiscing elit? & yes (fast) & Yes, there is a backup & No all data is lost &  xx \\ \hline
     
     \rowcolor[HTML]{C0C0C0} 
     \multicolumn{2}{|c|}{\cellcolor[HTML]{C0C0C0}Result} & \textbf{Low} & \textbf{Medium} & \textbf{High} & \cellcolor[HTML]{C0C0C0} \\ \cline{3-5}
     
     \multicolumn{2}{|c|}{\cellcolor[HTML]{C0C0C0}(check one of the three boxes)} &  &  &  & \multirow{-2}{*}{\cellcolor[HTML]{C0C0C0}} \\ \hline
\end{tabularx}
\label{table:Business consequences}
\end{table}


\end{document}
1
  • Exactly what i was hoping to achieve. Thanks a lot!
    – user230633
    Dec 9, 2020 at 17:02

You must log in to answer this question.