Formatting table

To learn about table design in general, I cannot praise the documentation of the booktabs package enough (see a before-and-after example from the documentation below). For your problem at hand, I would suggest to either come up with shorter column titles or to break them into several lines. This problem has been discussed as How to break a line in a table.

Example from the booktabs package about table design

In another answer Alan Munn has formatted the table from the question using the booktabs package and solved the problem how to break the column titles into two lines. I find it close to perfection.


Use the array package to have better control over table column specifications. Your problem is caused by the length of your column headings; you need to have specified widths but still centred titles. It's generally not advisable to have vertical lines in tables, nor to put the units (here '%') in each cell (they should go in the column heading). Given that all your numeric values are decimals, you also want to line up the decimal points. A right justified column can do this, but the dcolumn package provides more flexibility. As Christian mentions, the `booktabs package is the gold standard here.

Here's a version of your table using these principles.

\documentclass{article}
\usepackage{booktabs,array,dcolumn}

\newcolumntype{d}{D{.}{.}{2.3}}
\newcolumntype{C}{>{\centering}p}
\begin{document}
\begin{table}[htdp]
\caption{Comparison of Elements in Air on the Space Station and sea level on Earth}    
\centering
\begin{center}
\begin{tabular}{p{1.25in}ddd}
\toprule
\multicolumn{1}{C{1.25in}}{Chemical Component} & \multicolumn{1}{C{1in}}{Earth's Atmosphere (\%)} & \multicolumn{1}{C{1.25in}}{Ideal Values for the Space Station (\%)} &         \multicolumn{1}{C{1in}}{Astronaut Exhalation (\%)}\\
\midrule
Nitrogen & 78.084 & 78.000 & 74.200 \\
Oxygen & 20.946 & 21.000 & 15.300 \\
Argon & 0.934 & 0.000 & 0.000 \\
Carbon Dioxide & 0.033 & 0.000 & 3.600 \\
Water Vapour & 0.030 & 1.000 & 0.800 \\
Trace Elements & 0.003 & 0.000 & 0.800 \\ 
\bottomrule
\end{tabular}
\end{center}
\label{default}
\end{table}
\end{document}

output of code


\documentclass{article}
\usepackage{tabularx,ragged2e}
\newcolumntype{x}{>{\Centering}X}

\begin{document}
\begin{table}[htdp]
\caption{Comparison of Elements in Air on the Space Station and sea level on Earth}\label{default}
\begin{tabularx}{\linewidth}{|>{\RaggedRight}p{2.5cm}|x|x|x|}\hline
Chemical Component & Percentage in Earth's Atomsphere & Ideal Values for the Space Station & Astronaut Exhalation\\ \hline
Nitrogen      & 78.084\% & 78.000\% & 74.200\% \\ \hline
Oxygen        & 20.946\% & 21.000\% & 15.300\% \\ \hline
Argon         & 0.934\%  &  0.000\% &  0.000\% \\ \hline
Carbon Dioxide& 0.033\%  &  0.000\% &  3.600\% \\ \hline
Water Vapour  & 0.030\%  &  1.000\% &  0.800\% \\ \hline
Trace Elements& 0.003\%  &  0.000\% &  0.800\% \\ \hline
\end{tabularx}
\end{table}

\end{document}

btw: the vertical lines do not make a table more readable ...

Tags:

Tables