How to align table properly using tabularx

\subsection{Computed Results}

To prove the accuracy of the implementation there was a need to show that the answers that the application provides are within an acceptable range for the results. For this purpose a pre existing normal distribution implementation was used to calculate the error percentage of the computed answers. By looking at Error.java an example of the relative and absolute relative true error are shown, over three different data sets the following statistics could be extrapolated. Here are some of the error values
\begin{center}
\begin{tabularx}{\linewidth}{|p{1cm}|p{1cm}|p{1cm}|p{2cm}|p{2cm}|p{2cm}|p{2cm}|}
X & \mu & \sigma & Area of P(x) & Computed Area & Abs True Err & Abs Relative True Err \\
$5$ & $1.5$& $4$ & $0.747507$ & $0.747053$ & $0.000454649$ & $0.00060822$ \\
\end{tabularx}
\end{center}


Given the example tex above, I can't get the columns to line up and for it to fit inside the document neatly, as shown here

-
For tabularx to function "properly", you need at least one X-column. Perhaps one of the first three would work, or all of them. – Werner Dec 3 '12 at 18:59
@Werner still breaks the table – Jakob Bowyer Dec 3 '12 at 19:00
you would have had several TeX errors from that input \mu and \sigma are math mode so need to be $\mu$ and $\sigma$ P(x) should be $P(x)$ as well (although that one won't generate an error) – David Carlisle Dec 3 '12 at 19:02
And by "break[ing] the table", I assume that it doesn't fit within your text boundary (horizontally). You would either have to shrink some of the columns (not use fixed-width entries such as p{<len>}), or you'd have to increase the text boundary (using something like geometry), or accept an overlay of your table in your document (in, say, a centred format). – Werner Dec 3 '12 at 19:02
I actually have no idea – Jakob Bowyer Dec 3 '12 at 19:10

You can use the package tabulary instead:

And here is the MWE:

\documentclass{article}
\usepackage{tabulary}
\usepackage{tabularx}

\begin{document}
\section{Computed Results}

To prove the accuracy of the implementation there was a need to show that the answers that the application provides are within an acceptable range for the results. For this purpose a pre existing normal distribution implementation was used to calculate the error percentage of the computed answers. By looking at Error.java an example of the relative and absolute relative true error are shown, over three different data sets the following statistics could be extrapolated. Here are some of the error values
\begin{center}
\begin{tabulary}{\linewidth}{|L|L|L|L|L|L|L|}
X & $\mu$ & $\sigma$ & Area of P(x) & Computed Area & Abs True Err & Abs Relative True Err \\
$5$ & $1.5$& $4$ & $0.747507$ & $0.747053$ & $0.000454649$ & $0.00060822$ \\
\end{tabulary}
\end{center}
\end{document}


The result:

-

a TX version might look like this:

\documentclass{article}

\usepackage{tabularx}

\begin{document}
\section{Computed Results}

To prove the accuracy of the implementation there was a need to show that the answers that the application provides are within an acceptable range for the results. For this purpose a pre existing normal distribution implementation was used to calculate the error percentage of the computed answers. By looking at Error.java an example of the relative and absolute relative true error are shown, over three different data sets the following statistics could be extrapolated. Here are some of the error values
\begin{center}
\begin{tabularx}{\linewidth}{|*{3}{l|}*{4}{>{\raggedright\arraybackslash}X|}}
$X$ & $\mu$ & $\sigma$ & Area of $P(x)$ & Computed Area & Abs True Err & Abs Relative True Err \\
$5$ & $1.5$& $4$ & $0.747507$ & $0.747053$ & $0.000454649$ & $0.00060822$ \\
\end{tabularx}
\end{center}
\end{document}

-