2

I am new to LaTeX, but I have made a table using the code seen below before... I went to edit the table from an old template but received the extra alignment error. Can someone help spot where I went wrong or what I need to do?

\begin{center}
\begin{minipage}{\linewidth}
\centering
\captionof{table}{\bf{Calculations for Proctor Compaction}} 
\label{tab:Calculations for Proctor Compaction} 
\begin{tabular}{ C{1.25in} C{0.85in} *4{C{0.75in}}}\toprule[1.5pt]
\bf Property & \bf Unit & \bf Test 1 & \bf Test 2 & \bf Test 3 & \bf Test 4 & \bf Test 5 \\\midrule
\bf Mass of Soil in Oven Can & grams & 43.67 & 67.93 & 52.98 & 38.87 & 66.38  \\\\
\bf Mass of Water in Oven Can & grams & 2.14 & 4.98 & 5.93 & 5.66 & 10.24 \\\\
\bf Moisture Content & [\%] & 4.90 & 7.33 & 11.19 & 14.56 & 15.43  \\\\
\bf Moist Density of Compacted Soil & $\frac{g}{cm^{3}}$ & 1.83 & 1.99 & 2.09 & 2.02 & 1.92 \\\\
\bf Dry Density of Compacted Soil & $\frac{g}{cm^3}$ & 1.74 & 1.85 & 1.88 & 1.76 & 1.66 \\
\bottomrule[1.25pt]
\end{tabular}\par
\bigskip

\end{minipage}
\end{center}
6

You have 6 columns in definition of your tabular, but for example this line:

\bf Dry Density of Compacted Soil & $\frac{g}{cm^3}$ & 1.74 & 1.85 & 1.88 & 1.76 & 1.66 \\

has seven of them. You should probably add one column to your columns definition.

(And please consider changing an obsolete \bf something into \textbf{something}).

  • 1
    Or \bfseries which would also be appropriate and a parallel of the original switch – Au101 Oct 8 '17 at 23:53
  • @Au101 +1. Yes, in this case it will be easier to change by replacing \bf->\bfseries into an editor. – Przemysław Scherwentke Oct 8 '17 at 23:56
3

Some comments and observations:

  • As Przemysław Scherwentke has already pointed out in his answer, the main problem is that your table actually contains 7 columns, while you've only defined 6.

  • Do give some more thought to the way the tabular material is organized. I'd like to suggest that you not use any bold-facing at all. Instead, do provide alignment on the decimal markers in the five numeric columns, say, by loading the siunitx package and using its S column type.

  • Do also provide more standard ways to typeset scientific units. Again, if you're willing to load the siunitx package, use that package's \si macro to typeset units in ways that conform to international standards.

  • I'd also like to suggest that you use a tabularx environment and allow line-wrapping in the first column.

enter image description here

\documentclass{article}
\usepackage{tabularx,booktabs,ragged2e,caption}
\captionsetup{textfont=bf} % only if needed
\usepackage[per-mode=symbol]{siunitx}

\begin{document}
\begin{table}[ht!]
\setlength\tabcolsep{5pt} % default: 6pt
\captionsetup{skip=0.333\baselineskip} % amount of whitespace below caption
\caption{Calculations for Proctor Compaction} 
\label{tab:Calculations for Proctor Compaction} 

\begin{tabularx}{\textwidth}{@{} 
    >{\RaggedRight\hangindent=1em\hangafter=1}X 
    c 
    *{5}{S[table-format=2.2]} @{}}
\toprule
Property & Unit & {Test 1} & {Test 2} & {Test 3} & {Test 4} & {Test 5} \\
\midrule
Mass of Soil in Oven Can & grams & 43.67 & 67.93 & 52.98 & 38.87 & 66.38  \\ \addlinespace
Mass of Water in Oven Can & grams & 2.14 & 4.98 & 5.93 & 5.66 & 10.24 \\ \addlinespace
Moisture Content & [\%] & 4.90 & 47.33 & 11.19 & 14.56 & 15.43  \\ \addlinespace
Moist Density of Compacted Soil & \si{\gram\per\cubic\centi\meter} & 1.83 & 1.99 & 2.09 & 2.02 & 1.92 \\ \addlinespace
Dry Density of Compacted Soil & \si{\gram\per\cubic\centi\meter} & 1.74 & 1.85 & 1.88 & 1.76 & 1.66 \\ 
\bottomrule
\end{tabularx}
\end{table}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.