5

Is there any way of changing the height of the vertical lines of a tabular environment?

Here is my MWE:

\begin{tabular}{|c|c|}
\multicolumn{2}{|c|}{Header 1}\\
Subheader 1 & Subheader 2 \\ \hline
Cell 1 & Cell 2 \\ \hline
\end{tabular}

which generates:

enter image description here

However, I'd like to have the vertical line between Subheader 1 and Subheader 2 a bit shorter.

3

You can use the ! feature of the array package, together with \vline; however, it would be better not using vertical rules at all, as shown in the second table.

\documentclass{article}
\usepackage{array} % necessary for the shorter rule
\usepackage{booktabs} % for the second example
\begin{document}

\begin{tabular}{|c|c|}
\hline
\multicolumn{2}{|c|}{Header 1}\\
\multicolumn{1}{|c!{\vline height .8\ht\strutbox}}{Subheader 1} & Subheader 2 \\
\hline
Cell 1 & Cell 2 \\
\hline
\end{tabular}

\bigskip

\begin{tabular}{cc}
\toprule
\multicolumn{2}{c}{Header 1} \\
\addlinespace
Subheader 1 & Subheader 2 \\
\midrule
Cell 1 & Cell 2 \\
\bottomrule
\end{tabular}

\end{document}

enter image description here

1

use \multicolumn{2}{c}{Header 1} or:

\documentclass[fontsize=12pt]{scrartcl}
\usepackage{array}
\begin{document}

\begin{tabular}{|c|c|}
\multicolumn{2}{!{\vrule height 0.6ex}c!{\vrule height 0.6ex}}{Header 1}\\
Subheader 1 & Subheader 2 \\ \hline
Cell 1 & Cell 2 \\ \hline
\end{tabular}

\end{document}

enter image description here

1

If you only want the vertical line between Cell 1 and Cell 2 you can use

\multicolumn{1}{|c}{Subheader 1} & \multicolumn{1}{c|}{Subheader 2} \\.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.