Multicolumn giving last row extra space

multicolumntables

I have a problem when using multicolumn{}{}{} which causes the last column multicolumn takes to take more space than it needs.

This looks odd and in my case causes my table to span more than the width of the actual page.

It looks like this:

enter image description here

As you can see in the table above: "Trial 3" takes up more space than it needs which causes the last column to be out of the page's margin.

Code:

  \begin{table}
    \begin{tabular}{|c|c|c|c|c|c|c|}
      \hline
      \multirow{2}{*}{$\theta^\circ$} & \multirow{2}{*}{$\pm\delta\theta^\circ$}& \multicolumn{3}{c|}{Horizontal Displacement (m$\pm$0.1m)} & \multirow{2}{*}{Mean (m)} & \multirow{2}{*}{Mean Uncertainty ($\pm\delta$m)}\\\cline{3-5}
      & & Trial 1 & Trial 2 & Trial 3 & &\\
      \hline\hline
      25 & 0.41 & 6.3 & 12.0 & 13.7 & 10.7 & 2.9\\
      \hline
      30 & 0.38 & 15.1 & 9.2 & 14.1 & 12.8 & 2.4\\
      \hline
      35 & 0.37 & 14.3 & 17.6 & 8.4 & 13.4 & 3.4\\
      \hline
      40 & 0.37 & 13.4 & 12.4 & 12.1 & 12.6 & 0.5\\
      \hline
      45 & 0.38 & 13.6 & 12.9 & 14.1 & 13.5 & 0.4\\
      \hline
      50 & 0.40 & 17.8 & 15.4 & 19.9 & 17.7 & 1.5\\
      \hline
      55 & 0.43 & 16.9 & 13.7 & 19.6 & 16.7 & 2.0\\
      \hline
      60 & 0.47 & 14.9 & 19.2 & 17.9 & 17.3 & 1.6\\
      \hline
      65 & 0.55 & 13.6 & 16.5 & 14.1 & 14.7 & 1.2\\
      \hline
    \end{tabular}
    \caption{Data table}
    \label{DataTable}
  \end{table}

Best Answer

You just need to make sure that the heading is not wider than the columns it spans either making the columns wider or the heading narrow. I show an example below although it would look better without all the horizontal and vertical rules.

enter image description here

\documentclass{article}
\usepackage{dcolumn}
\begin{document}

\begin{table}
\centering
\setlength\extrarowheight{2pt}
    \begin{tabular}{|c|D..{1.2}|D..{2.1}|D..{2.1}|D..{2.1}|D..{2.1}|D..{1.1}|}
      \hline
      \multicolumn{1}{|c|}{$\theta^\circ$} &
 \multicolumn{1}{c|}{$\pm\delta\theta^\circ$}& 
\multicolumn{3}{c|}{\begin{tabular}{@{}c@{}}Horizontal Displacement\\ (m$\pm$0.1m)\end{tabular}} &
 \multicolumn{1}{c|}{\begin{tabular}{@{}c@{}}Mean\\ (m)\end{tabular}} & 
 \multicolumn{1}{c|}{\begin{tabular}{@{}c@{}}Mean Uncertainty\\ ($\pm\delta$m)\end{tabular}}\\
\cline{3-5}
      & &  \multicolumn{1}{c|}{Trial 1} &  \multicolumn{1}{c|}{Trial 2} &  \multicolumn{1}{c|}{Trial 3} & &\\
      \hline\hline
      25 & 0.41 & 6.3 & 12.0 & 13.7 & 10.7 & 2.9\\
      \hline
      30 & 0.38 & 15.1 & 9.2 & 14.1 & 12.8 & 2.4\\
      \hline
      35 & 0.37 & 14.3 & 17.6 & 8.4 & 13.4 & 3.4\\
      \hline
      40 & 0.37 & 13.4 & 12.4 & 12.1 & 12.6 & 0.5\\
      \hline
      45 & 0.38 & 13.6 & 12.9 & 14.1 & 13.5 & 0.4\\
      \hline
      50 & 0.40 & 17.8 & 15.4 & 19.9 & 17.7 & 1.5\\
      \hline
      55 & 0.43 & 16.9 & 13.7 & 19.6 & 16.7 & 2.0\\
      \hline
      60 & 0.47 & 14.9 & 19.2 & 17.9 & 17.3 & 1.6\\
      \hline
      65 & 0.55 & 13.6 & 16.5 & 14.1 & 14.7 & 1.2\\
      \hline
    \end{tabular}
    \caption{Data table}
    \label{DataTable}
  \end{table}
\end{document}