[Tex/LaTex] Formatting table

tables

I have a table that is created with the following code:

\begin{table}[htdp]
\caption{Comparison of Elements in Air on the Space Station and sea level on Earth}    
\centering
\begin{center}
\begin{tabular}{|c|c|c|c|}
\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{tabular}
\end{center}
\label{default}
\end{table}

But it sticks over the page so how could i format it so that it fits on a page in portrait mode not landscape.

Best Answer

\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 ...

Related Question