[Tex/LaTex] Proper Formatting for Simple Tables in LaTeX

tables

I have a table as below that doesn't format properly through pdfLaTeX. Specifically, the vertical lines for each row don't extend all the way down to create a complete box. Is there a better way to do this? The code is below.

  \begin{table}[!ht]
    \fontsize{12}{12}\selectfont
    \caption{Caption.}\label{label}
    \center{
    \begin{tabular}{|c|c|c|c|}
    \hline
    &a&b&c&d\\
    \hline
    &e&f&g&h\\
    \hline
    &i&j&k&l\\
    \end{tabular}
    }
    \end{table}

Best Answer

Summarizing the comments made above, you should consider using the following code to create the sample 3 by 4 table:

\documentclass[10pt]{article}
\begin{document}
  \begin{table}[!ht]
    \large        %% not "\fontsize{12}{12}\selectfont"
    \caption{Caption.}\label{label}
    \centering    %% not "\center{...}"
    \begin{tabular}{|c|c|c|c|}
    \hline
    a&b&c&d\\     %% no "&" at start of row
    \hline
    e&f&g&h\\
    \hline
    i&j&k&l\\
    \hline        %% extra \hline at bottom of table
    \end{tabular}
  \end{table}
\end{document}

enter image description here

I trust you are working your way toward creating somewhat more exciting tables than the one above. When you do, you should aim for an open, "breathing" look -- rather than one dominated by lots and lots of little "jail cells" that imprison the data. A great place to start this quest is the user guide of the booktabs package; it provides a wonderful guide to open, interesting, and clean-looking tables.

Related Question