multirow
我正在尝试使用和绘制表格multicolumn
,并且我想在单元格周围使用边框。当我使用 时\cline
,会出现以下情况
\begin{table}
\begin{center}
\begin{adjustbox}{width=0.92\linewidth,center}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{Activity} & \multirow{2}{*}{Predecessor} & \multirow{2}{*}{Normal duration (days)} & \multirow{2}{*}{Crashed duration (days)} & \multirow{2}{*}{Normal cost (\$)} & \multicolumn{3}{c|}{Cost of crashes (\$)} \\ \cline{6-8}
& & & & & $1^{st}$ crash &$2^{nd}$ crash &$3^{rd}$ crash \\ \hline
A & \dots & \dots & \dots & \dots & \dots &\dots & \dots \\ \hline
B & \dots & \dots & \dots & \dots & \dots &\dots & \dots \\ \hline
C & \dots & \dots & \dots & \dots & \dots &\dots & \dots \\ \hline
D & \dots & \dots & \dots & \dots & \dots &\dots & \dots \\ \hline
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots &\vdots & \vdots \\ \hline
\end{tabular}
\end{adjustbox}
\end{center}
\caption{\small {\bf Representation of a typical project crashing problem.}}
\label{table:phase_classification}
\end{table}
结果是下表的边框不完整,
问题似乎没有发生在\hline
:
我该如何使用\cline
它才不会导致如上例中那样的边框不完整?谢谢!
答案1
我无法从你的代码中重现这个问题。不过,外观和不是缩放表格,这将导致文本太小。
\documentclass{article}
\usepackage{multirow,adjustbox}
\usepackage{caption}
\usepackage{booktabs}
\newcommand{\tsplitcell}[1]{%
\smash{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}%
}
\begin{document}
\begin{table}
\begin{center}
\begin{adjustbox}{width=0.92\linewidth,center}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{Activity} & \multirow{2}{*}{Predecessor} & \multirow{2}{*}{Normal duration (days)} & \multirow{2}{*}{Crashed duration (days)} & \multirow{2}{*}{Normal cost (\$)} & \multicolumn{3}{c|}{Cost of crashes (\$)} \\ \cline{6-8}
& & & & & $1^{st}$ crash &$2^{nd}$ crash &$3^{rd}$ crash \\ \hline
A & \dots & \dots & \dots & \dots & \dots &\dots & \dots \\ \hline
B & \dots & \dots & \dots & \dots & \dots &\dots & \dots \\ \hline
C & \dots & \dots & \dots & \dots & \dots &\dots & \dots \\ \hline
D & \dots & \dots & \dots & \dots & \dots &\dots & \dots \\ \hline
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots &\vdots & \vdots \\ \hline
\end{tabular}
\end{adjustbox}
\end{center}
\caption{\small {\bf Representation of a typical project crashing problem.}}
\label{table:phase_classification}
\end{table}
\begin{table}[htp]
\centering\small
\begin{tabular}{@{}cccccccc@{}}
\toprule
Activity &
Predecessor &
\multicolumn{2}{c}{Duration (days)} &
\tsplitcell{Normal \\ cost (\$)} &
\multicolumn{3}{c}{Cost of crashes (\$)} \\
\cmidrule(lr){3-4} \cmidrule(lr){6-8}
& & Normal & Crashed & & First & Second & Third \\
\midrule
A & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
B & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
C & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
D & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\
\bottomrule
\end{tabular}
\captionsetup{font=bf,size=small}
\caption{Representation of a typical project crashing problem.}
\end{table}
\end{document}
通常,\captionsetup
命令应该位于文档序言中,因此其效果会影响每个标题。