I am trying to create a table similar to the one that can be seen below. In the Description column (4th column) one can see that the text takes multiple rows whilst in the Procedure column (5th column) there are two rows fitting in the same space with an hline dividing each cell. How may I achieve this effect?
I've spent hours playing around with this but lines aren't coming right.
\begin{table}[H]
\begin{tabular}{C{3cm} | C{3cm} | C{4cm} | C{2cm} | C{2cm}}
\bfseries{Use Case} & \bfseries{Test Case} & \bfseries{Description} & \bfseries{Procedure} & \bfseries{Expected Result} \\ \hline
\multirow{2}{*}{UC01: Field Creator} & \multirow{2}{*}{TC01: Save a new job} & {Admin creates necessary variables associated with a job and names the job. The admin then saves the file. & Procedure 1 & bla bla bla \\ \cline{4-5}
\end{tabular}
\end{table}
Thanks for your patience and your time.
Best Answer
You don't want to use
[H]
as an option fortabular
, generally.When you have a
\multirow
, you need to have a "phantom column" in the next lower row. For example, if you have\multirow{2}{*}{stuff} & more stuff \\
then the row below it requires something like& second row stuff \\
.So, in your example, you'll need six phantom rows in the first column. In the second column, you'll have
\multirow
, below it a phantom column, below it\multirow
, below it a phantom column, etc.The
@{}
means no padding on that side of the cell(s). Whereas@{\hskip 5pt}
means a padding of5pt
between the cells. This was arbitrary and just to reduce the space slightly from the default padding. You can change the value or delete@{\hskip 5pt}
altogether, depending on your preference.You need
\\
after every single row in your table. There are eight rows here, and you'll see eight\\
. In your code snippet, there were only two\\
. (If you have four rows and two\multirow{2}{...}{...}
, you'll still want two phantom rows/columns with\\
.Lastly, many people will tell you that you shouldn't use vertical lines in your table. I put them in because that's what your image has. I think there are certain case where they are ok, and I know some cases where they are required. But just be aware that this table looks better with only horizontal lines, as in the snippet below: