我正在尝试制作一个包含多个多列和 tabularx 的表格。似乎我在某个地方有一个隐藏的列,我无法摆脱它。这是最小的可重现示例:
\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}
输出结果如下:
我不明白为什么那一栏看起来像是被分成了两半,也不明白为什么有些单词之间有难看的水平间距
答案1
过长的结果文本迫使列过宽。您可以在那里使用 ap 列,但文本换行后它不再位于框上方,因此无论如何都需要重新措辞,因此更简单的方法是只使用两个条目并摆脱多行。此外,不要忘记在有时重新插入垂直规则\multicolumn
\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}