When aligning tabular
environments with the [t]
option, one can use \firsthline
(from the array package) instead of \hline
when a line is required at the top of the table. Like so:
\documentclass{article}
\usepackage{array}
\begin{document}
Tabular with hline:
\begin{tabular}[t]{ll}
\hline A & B \\ C & D \\ \hline
\end{tabular}
and with firsthline:
\begin{tabular}[t]{ll}
\firsthline A & B \\ C & D \\ \lasthline
\end{tabular}
But what if I want only some cells of the first line to have a line above them, like this:
Tabular with cline:
\begin{tabular}[t]{ll}
\cline{2-2} A & B \\ C & D \\ \hline
\end{tabular}
and what it should look like:
\raisebox{.8em}{
\begin{tabular}[t]{ll}
\cline{2-2} A & B \\ C & D \\ \hline
\end{tabular}
}
\end{document}
And the compiled result:
Is there any easy way to achieve this effect without manually tweaking the vertical offset with \raisebox
?
Best Answer
You can define a command
\firscline
similar to\firsthline
but using\cline
instead of\hline
: