我正在尝试构建一个带有类似此标题的表格,并合并所有列并在其下方写入文本。
\begin{table*}
\caption{The Caption}
\centering
\begin{tabular}{|*{6}{c|}}
\hline
\multicolumn{1}{|c|}{WP Number} & \multicolumn{1}{|c|}{WP1} &
\multicolumn{1}{|c|}{WP Title} & \multicolumn{1}{|c|}{Foo} &
\multicolumn{1}{|c|}{Start-End Date} & \multicolumn{1}{|c|}{Baz} \\ \hline
foo bar baz are related to bar baz and band
%& & & & & & \\ \hline
\end{tabular}
我尝试在网上寻找一些例子来展示这个图形,但是没有成功。
答案1
如果第一行的对齐方式与常规对齐方式没有区别,则不需要所有这些\multicolumn
命令。要将所有列合并到一行中的单个单元格,您可以使用\multicolumn
...
\documentclass[]{article}
\begin{document}
\begin{table}
\caption{The Caption}
\centering
\begin{tabular}{|*{6}{c|}}
\hline
WP Number & WP1 & WP Title & Foo & Start-End Date & Baz\\
\hline
\multicolumn{6}{|c|}{foo bar baz are related to bar baz and band}\\
\hline
foo & bar & baz & bar & foo &\\
\hline
\end{tabular}
\end{table}
\end{document}
另外,为了在视觉上增强表格,我不会使用垂直线,而是用\hline
、和替换booktabs
s :\toprule
\midrule
\bottomrule
\documentclass[]{article}
\usepackage{booktabs}
\begin{document}
\begin{table}
\caption{The Caption}
\centering
\begin{tabular}{*{6}{c}}
\toprule
WP Number & WP1 & WP Title & Foo & Start-End Date & Baz\\
\midrule
\multicolumn{6}{c}{foo bar baz are related to bar baz and band}\\
\midrule
foo & bar & baz & bar & foo & band\\
foo & bar & baz & bar & foo & band\\
\midrule
\multicolumn{6}{c}{foo bar baz are related to bar baz and band}\\
\midrule
foo & bar & baz & bar & foo & band\\
foo & bar & baz & bar & foo & band\\
\bottomrule
\end{tabular}
\end{table}
\end{document}