I was wondering how I could frame a table (with borders to form a box) when it has spacing. For instance, I know that this works with:
...
\begin{tabular}[t]{ | r l r l r | }
\hline
a & b & c & d & e \\
\hline
\end{tabular}
...
and gives a box. The problem I'm having is when I want to put spacing between the horizontal line and the data:
\hline
\\[-2.3mm]
a & b & c & d & e \\
\\[-2.3mm]
\hline
This results in the small spaces and doesn't connect the borders. Any suggestions?
Also, is there a way to fill in a background color for certain cells within a table? Any feedback would be extremely helpful and very much appreciated. Thanks!
General ⇒ framing and highlighting in tabular environments
NEW: TikZ book now 40% off at Amazon.com for a short time.

-
- Posts: 707
- Joined: Tue Mar 25, 2008 5:02 pm
framing and highlighting in tabular environments
The code you sent is broken, but if I add two extra columns I get something that I think represents what you were looking for.
LaTeX isn't generating the vertical bars where you want them because the row is blank. You could get around this by simply putting four row separators in the rows, but that's even sloppier.
Instead, use a strut (vertical, zero-width rule) and change the row height:
LaTeX isn't generating the vertical bars where you want them because the row is blank. You could get around this by simply putting four row separators in the rows, but that's even sloppier.
Instead, use a strut (vertical, zero-width rule) and change the row height:
Code: Select all
\documentclass{article}
\begin{document}
\begin{tabular}[t]{|l|l|l|l|l|}
\hline
\rule{0pt}{5mm}%
a & b & c & d & e \\[2mm]
\hline
\end{tabular}
\end{document}