1

I am trying to draw a table using multirow and multicolumn, and I would like to use borders around cells. When I use \cline, with the following

\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}

It results in the following table with incomplete borders,

enter image description here

The problem doesn't seem to happen with \hline:

enter image description here

How can I use \cline such that it doesn't result in incomplete borders as in the example above? Thank you!

1
  • Perhaps the journal template you use redefines \cline to add pre- and post- vertical skips. Mar 20, 2022 at 19:59

1 Answer 1

2

I cannot reproduce the issue from your code. However, there is space for improving the appearance and not scaling the table, which will result in too small text.

\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}

enter image description here

Typically, the \captionsetup command should be in the document preamble, so its effect is on every caption.

2
  • Thank you, indeed, without vertical lines, it looks much nicer! For some reason, I cannot produce the same output table you get with the vertical lines, but instead I get disconnected vertical lines as shown in my original post (maybe due to some predefined packages in the journal template that I am using). In any case, I will use the table without vertical lines. Thanks!
    – tebu
    Feb 18, 2022 at 17:23
  • 1
    You can as well upvote (if the answer is useful) or accept it as an answer if the solution has solved your problem @tebu
    – itc
    Jul 18, 2022 at 20:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .