Probably you also want to center the cells vertically. LaTeX tabular
s have a different spacing model as HTML. Invisible struts help to keep a uniform line spacing. Via struts, the \baselineskip
space is divided in 70% above and 30% below the base line. Since your text does not contain glyphs with descenders, the space below the base line looks too large in comparison to the space above the text.
The following example shows some workarounds. For simplicity the vertical margins will use the same as the horizontal: \tabcolsep
.
By redefining
\renewcommand*{\arraystretch}{0}
the effect of the struts are nullified. The margin below can be added via the optional argument of \\
. The margin above can be created by increasing the height of the row. \raisebox{\tabcolsep}{\vphantom{L}}
applied to the highest letter L
creates this invisible artificial height.
The next example uses an additional row instead with the height of the margin.
The example file concludes with an example, how this can be done with \fbox
.
\kern\fboxrule
prevents the double line width of the touching \fbox
es.
Package array
moves the vertical lines outside the cells. The effect is visible in comparison with the \fbox
example. With package array
the widths are the same. Otherwise, the tabular
examples have smaller widths.
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}{|c|c|} \hline
Lolcats & .com \\ \hline
\end{tabular}
\begingroup
\renewcommand*{\arraystretch}{0}%
\begin{tabular}{|c|c|} \hline
\raisebox{\tabcolsep}{\vphantom{L}}%
Lolcats & .com \\[\tabcolsep]
\hline
\end{tabular}
\endgroup
\begingroup
\renewcommand*{\arraystretch}{0}%
\begin{tabular}{|c|c|} \hline
\rule{0pt}{\tabcolsep} & \\
Lolcats & .com \\[\tabcolsep]
\hline
\end{tabular}
\endgroup
\setlength{\fboxsep}{\tabcolsep}
\fbox{Lolcats}\kern-\fboxrule\fbox{\vphantom{L}.com}
\end{document}

\centering
supposed to do? The column already has center alignment.c|c
withr|r
. I have greatly simplified my original table, in which the\centering
command does have an effect.r,l,c
all make a box that is just wide enough for the cell to fit in.\multicolumn{1}{c}{Lolcats}
(add also the rules, if you really want ruled tables). Please, make a more significant example.