1

enter image description here

The code I currently have is:

\documentclass{article}
\usepackage{geometry}
  \geometry{a4paper,   % note: 'a4paper', not 'a3paper'
            showframe, % omit 'showframe' option in real document
            %total={170mm,300mm},
            %left=20mm, top=20mm,
            margin=20mm
  }
\usepackage{siunitx,booktabs}
\newcolumntype{T}[1]{S[table-format=#1]}

\begin{document}
\begin{center}
\sisetup{round-mode=places,round-precision=2}
\begin{tabular}{ @{} 
                 T{1.2} 
                 *{5}{T{2.2}} 
                 S[table-format=2.3,round-precision=3] 
                 S[table-format=1.3,round-precision=2] X @{}}
 \toprule
 {Mass/ $m$, \unit{\kilo\gram}} &
 \multicolumn{6}{c}{Frequency/ $f$, \unit{\hertz} $\pm 0.001$} & {\shortstack{uncertainty in \\ average value,$f$ /\unit{\hertz}}} & {\shortstack{Tension \\/ $T$, \unit{\newton}}}& {$\Delta$T/ $T$, \unit{\newton}} \\
 \cmidrule(lr){2-7}
 & {Trial 1} & {Trial 2} & {Trial 3} & {Trial 4} & {Trial 5} & {Average} \\
 \midrule
 0.050 & 16.200 & 16.630 & 16.560 & 16.840 & 16.550 & 16.556 & 0.32 & 0.491 & 0.098 \\
 0.100 & 23.650 & 22.800 & 22.810 & 22.970 & 22.700 & 22.986 & 
 0.48 & 0.981 & 0.098\\
 0.150 & 28.060 & 27.650 & 27.600 & 27.470 & 27.440 & 26.644 & 
 0.31 & 1.472 & 0.098\\
 0.200 & 34.300 & 32.030 & 32.340 & 32.380 & 32.030 & 32.616 & 1.14 & 1.962 & 0.098\\
 0.250 & 35.500 & 35.480 & 35.420 & 35.520 & 35.350 & 35.454 & 0.09 & 2.453 & 0.098\\
 0.300 & 38.780 & 38.820 & 38.580 & 39.000 & 38.790 & 38.794 & 0.21 & 2.943 & 0.098\\
 0.350 & 41.800 & 42.050 & 41.750 & 41.980 & 41.950 & 41.906 & 0.15 & 3.434 & 0.098\\
 0.400 & 44.400 & 44.760 & 44.670 & 45.020 & 44.900 & 44.750 & 0.31 & 3.924 & 0.098\\
 0.450 & 47.450 & 47.550 & 47.520 & 47.500 & 47.650 & 47.534 & 0.10 & 4.415 & 0.098\\
 0.500 & 50.350 & 50.190 & 49.840 & 50.170 & 49.900 & 50.090 & 0.25 & 4.905 & 0.098\\
 \bottomrule
\end{tabular}
\end{center}

But this only produces enter image description here

How can I achieve this?

2
  • The code doesn't compile on my machine. Mar 22 at 1:35
  • Judging from your picture, it looks like the table is too wide. So you probably have to display the table in landscape mode. You may also consider splitting the table into more than one table. Mar 22 at 1:38

1 Answer 1

2
  • For the last column you use X column, which is not defined (you not load tabularx package.
  • You have mismatch in number of define table columns (9) and used (10), remedy is to add one more column in their definitions.
  • For better spacing table in text block is sensible sine column headers (first and last three) write in multirow cells:
\documentclass{article}
\usepackage{geometry}
  \geometry{a4paper,   % note: 'a4paper', not 'a3paper'
            showframe, % omit 'showframe' option in real document
            %total={170mm,300mm},
            %left=20mm, top=20mm,
            margin=20mm
  }
\usepackage{booktabs, siunitx}
\newcolumntype{T}[1]{S[table-format=#1]}
\usepackage{multirow}

\begin{document}
\begin{center}
\sisetup{round-mode=places,round-precision=2}
\begin{tabular}{ @{}
                 T{1.2}
                 *{5}{T{2.2}}
                 S[table-format=2.3,round-precision=3]
                 S[table-format=1.3,round-precision=2] 
                 c 
                 c  % <--- added
                 @{}}
 \toprule
{\multirow{2}{*}{\shortstack{Mass $m$\\ \unit{\kilo\gram}}}} 
    & \multicolumn{6}{c}{Frequency $f$, \unit{\hertz} $\pm 0.001$} 
                            & {\multirow{2}{*}{\shortstack{uncertainty\\[-2pt] in average\\[-2pt] value,$f$ \unit{\hertz}}}} 
                                & {\multirow{2}{*}{\shortstack{Tension $T$\\ \unit{\newton}}}}
                                    & {\multirow{2}{*}{\shortstack{$\Delta T/T$,\\ \unit{\newton}}}} \\
\cmidrule(lr){2-7}
    & {Trial 1} 
        & {Trial 2} 
            & {Trial 3} 
                & {Trial 4} 
                    & {Trial 5} 
                        & {Average} 
                            &   &   &   \\  % added missed ampersands   
                                
    \midrule
0.050 & 16.200 & 16.630 & 16.560 & 16.840 & 16.550 & 16.556 & 0.32 & 0.491 & 0.098 \\
0.100 & 23.650 & 22.800 & 22.810 & 22.970 & 22.700 & 22.986 & 0.48 & 0.981 & 0.098 \\
0.150 & 28.060 & 27.650 & 27.600 & 27.470 & 27.440 & 26.644 & 0.31 & 1.472 & 0.098 \\
0.200 & 34.300 & 32.030 & 32.340 & 32.380 & 32.030 & 32.616 & 1.14 & 1.962 & 0.098\\
0.250 & 35.500 & 35.480 & 35.420 & 35.520 & 35.350 & 35.454 & 0.09 & 2.453 & 0.098\\
0.300 & 38.780 & 38.820 & 38.580 & 39.000 & 38.790 & 38.794 & 0.21 & 2.943 & 0.098\\
0.350 & 41.800 & 42.050 & 41.750 & 41.980 & 41.950 & 41.906 & 0.15 & 3.434 & 0.098\\
0.400 & 44.400 & 44.760 & 44.670 & 45.020 & 44.900 & 44.750 & 0.31 & 3.924 & 0.098\\
0.450 & 47.450 & 47.550 & 47.520 & 47.500 & 47.650 & 47.534 & 0.10 & 4.415 & 0.098\\
0.500 & 50.350 & 50.190 & 49.840 & 50.170 & 49.900 & 50.090 & 0.25 & 4.905 & 0.098\\
 \bottomrule
\end{tabular}
\end{center}
\end{document}

enter image description here

Addendum:

  • With use `tabular* table is nicer spaced in text,
  • Since all numbers in some columns has the same format, they can be nice aligned also in c column (as already are now in the last two columns), the MWE can be simplified to:
\documentclass{article}
\usepackage{geometry}
  \geometry{a4paper,
            margin=20mm,
            showframe,
            }
\usepackage{booktabs, multirow, siunitx}

\begin{document}

\begin{center}
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{ @{\extracolsep{\fill}} *{10}{c} @{}}
    \toprule
\multirow{2}{*}{\shortstack{Mass $m$\\ \unit{\kilo\gram}}}
    & \multicolumn{6}{c}{Frequency $f$, \unit{\hertz} $\pm 0.001$}
                            & \multirow{2}{*}{\shortstack{uncertainty\\[-2pt] in average\\[-2pt] value, $f$ \unit{\hertz}}}
                                & \multirow{2}{*}{\shortstack{Tension $T$\\ \unit{\newton}}}
                                    & \multirow{2}{*}{\shortstack{$\Delta T/T$,\\ \unit{\newton}}} \\
    \cmidrule(lr){2-7}
    & Trial 1
        & Trial 2
            & Trial 3
                & Trial 4
                    & Trial 5
                        & Average
                            &   &   &   \\  % added missed ampersands

    \midrule
% rest of table body is the same as before

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .