I am wanting to create a table as a header in LaTeX. 3 columns, the first cell must span two rows, the second cell must span two rows and the third cell must be split between the two rows. So 4 cells total but 3 columns like the picture below. Im having trouble with the spacing when I try and split the last column into two rows.
Asked
Active
Viewed 1.3k times
2 Answers
5
One first sketch:
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{|c|c|c|}
\hline
\multirow{2}{*}{Some text A} & \multirow{2}{*}{Some text B} & Some text C\\
\cline{3-3}
& & Some text D\\
\hline
\end{tabular}
\end{document}
This gives you:
It is not clear to me if you want your middle column to be larger than the two on the sides. Anyway, see this other answer of mine!

MattAllegro
- 6,455
- 5
- 45
- 52
-
Many thanks. When using \centering for text C and D it shifts the clone to the first cell. Is there a fix for this? – Duncan William Gibbons Jul 16 '20 at 09:00
-
@DuncanWilliamGibbons text C and text D are centered by default (check it with a longer text)...and I think \centering within one cell is not the way – MattAllegro Jul 16 '20 at 16:18
1
The tabularray
package makes merging cells very easy:
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\noindent%
\begin{tblr}{
colspec={lXc},
vlines,
hlines
}
\SetCell[r=2]{} some text & \SetCell[r=2]{} some long text some long text some long text & short text\\
&& short text\\
\end{tblr}
\end{document}

samcarter_is_at_topanswers.xyz
- 33,336
- 5
- 41
- 62