4

I am using the multicolumn command within tabularx and am not getting any joy. I want to organise it so that the top line spans across two separate columns and wraps itself appropriately, but I cant get it working.

\def\tabularxcolumn#1{m{#1}}

\begin{table}[htbp]
{\small
\hfill{}  \centering
  \caption{Add caption}
    \begin{tabularx}{\linewidth}{*{12}{>{\centering\arraybackslash}X}}
    \toprule
    \multicolumn{2}{X}{} & \multicolumn{2}{X}{Experimental Frequency (Hz) \citep{Saiidi1994}} & \multicolumn{2}{X}{\cite{Kim2004} Analytical Model Predicted Frequency (Hz)} & \multicolumn{2}{X}{} & \multicolumn{2}{X}{\cite{Kim2004} FE Model Predicted Frequency (Hz)} &\multicolumn{2}{X}{} \\
    \cline{3-12}
    Case  & In-situ prestress force (kN) & Mode 1 & Mode 2 & Mode 1 & Mode 2 & Mode 1 (\% diff) & Mode 2 (\% diff) & Mode 1 & Mode 2 & Mode 1 (\% diff) & Mode 2 (\% diff) \\
    \midrule
    1     & 0.00  & 11.41 & 43.99 & 11.41 & 45.64 & 0.0\% & -3.7\% & 11.20 & 44.05 & 1.9\% & -0.1\% \\
    2     & 15.71 & 12.09 & 44.11 & 11.83 & 46.06 & 2.1\% & -4.4\% & 11.69 & 44.55 & 3.3\% & -1.0\% \\
    3     & 27.05 & 13.47 & 44.89 & 12.13 & 46.37 & 10.0\% & -3.3\% & 12.03 & 44.89 & 10.7\% & 0.0\% \\
    4     & 36.49 & 12.89 & 44.69 & 12.37 & 46.63 & 4.0\% & -4.3\% & 12.31 & 45.16 & 4.5\% & -1.1\% \\
    5     & 57.25 & 13.63 & 45.62 & 12.89 & 47.18 & 5.5\% & -3.4\% & 12.90 & 45.74 & 5.3\% & -0.3\% \\
    6     & 81.81 & 14.49 & 45.57 & 13.47 & 47.83 & 7.1\% & -5.0\% & 13.57 & 46.40 & 6.4\% & -1.8\% \\
    7     & 91.26 & 14.72 & 46.32 & 13.69 & 48.07 & 7.0\% & -3.8\% & 13.82 & 46.65 & 6.1\% & -0.7\% \\
    8     & 121.46 & 14.72 & 45.86 & 14.36 & 48.85 & 2.4\% & -6.5\% & 14.58 & 47.40 & 1.0\% & -3.4\% \\
    9     & 130.91 & 14.97 & 46.10 & 14.57 & 49.10 & 2.7\% & -6.5\% & 14.81 & 47.62 & 1.1\% & -3.3\% \\
    10    & 132.80 & 15.07 & 45.87 & 14.61 & 49.15 & 3.1\% & -7.1\% & 14.86 & 47.67 & 1.4\% & -3.9\% \\
    \bottomrule
    \end{tabularx}%
  \label{tab:addlabel}
  }
\end{table}%
  • sorry i wasnt allowed to post the output picture – nobleda Jun 14 '13 at 16:11
2

I don't think tabularx is gaining you anything here, most of the table data is numeric so can't line wrapped to different lengths. I think I'd do something more like this, perhaps some more refinements but...

enter image description here

\documentclass{article}
\usepackage{tabularx,booktabs}
\def\citep#1{#1}
\begin{document}

\def\tabularxcolumn#1{m{#1}}

\begin{table}[htbp]
\small \setlength\tabcolsep{2pt}
\centering
  \caption{Add caption}

    \hspace*{-1cm}\begin{tabular}{*{12}{r}}
    \toprule
    Case &
    \multicolumn{1}{p{1.5cm}}{\centering In-situ prestress force (kN)}& 
\multicolumn{2}{p{3cm}}{\centering Experimental Frequency (Hz) \citep{Saiidi1994}} &
 \multicolumn{4}{p{5cm}}{\centering \cite{Kim2004} Analytical Model Predicted Frequency (Hz)} & 
\multicolumn{4}{p{5cm}}{\cite{Kim2004} FE Model Predicted Frequency (Hz)}  \\
    \cline{3-12}
 &  & Mode 1 & Mode 2 & Mode 1 & Mode 2 & Mode 1  & Mode 2  & Mode 1 & Mode 2 & Mode 1  & Mode 2 \\
 &  &  &  &  &  &  (\% diff) &(\% diff) &  &  &  (\% diff) & (\% diff) \\
    \midrule
    1     & 0.00  & 11.41 & 43.99 & 11.41 & 45.64 & 0.0\% & -3.7\% & 11.20 & 44.05 & 1.9\% & -0.1\% \\
    2     & 15.71 & 12.09 & 44.11 & 11.83 & 46.06 & 2.1\% & -4.4\% & 11.69 & 44.55 & 3.3\% & -1.0\% \\
    3     & 27.05 & 13.47 & 44.89 & 12.13 & 46.37 & 10.0\% & -3.3\% & 12.03 & 44.89 & 10.7\% & 0.0\% \\
    4     & 36.49 & 12.89 & 44.69 & 12.37 & 46.63 & 4.0\% & -4.3\% & 12.31 & 45.16 & 4.5\% & -1.1\% \\
    5     & 57.25 & 13.63 & 45.62 & 12.89 & 47.18 & 5.5\% & -3.4\% & 12.90 & 45.74 & 5.3\% & -0.3\% \\
    6     & 81.81 & 14.49 & 45.57 & 13.47 & 47.83 & 7.1\% & -5.0\% & 13.57 & 46.40 & 6.4\% & -1.8\% \\
    7     & 91.26 & 14.72 & 46.32 & 13.69 & 48.07 & 7.0\% & -3.8\% & 13.82 & 46.65 & 6.1\% & -0.7\% \\
    8     & 121.46 & 14.72 & 45.86 & 14.36 & 48.85 & 2.4\% & -6.5\% & 14.58 & 47.40 & 1.0\% & -3.4\% \\
    9     & 130.91 & 14.97 & 46.10 & 14.57 & 49.10 & 2.7\% & -6.5\% & 14.81 & 47.62 & 1.1\% & -3.3\% \\
    10    & 132.80 & 15.07 & 45.87 & 14.61 & 49.15 & 3.1\% & -7.1\% & 14.86 & 47.67 & 1.4\% & -3.9\% \\
    \bottomrule
    \end{tabular}\hspace*{-1cm}
  \label{tab:addlabel}

\end{table}%

\end{document}
  • Thank you David, your feedback is much appreciated!!, But is the solution simply to manually edit the column widths? – nobleda Jun 14 '13 at 16:37
  • @nobleda it's possible to make it a bit more automatic and if you were printing database output with thousands of tables a week you would want that, but if it was my data and my table, I'd do it by hand and not use tabularx (even if I wrote that package:-) – David Carlisle Jun 14 '13 at 17:41

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.