1

I wanted to put my data in a multi column and multi row table, whilst aligning the entries by decimal point. For that I am using the package siunitx. There problem lies within the formatting of the three sub columns: 'Position 1', 'Position 2' and 'Position 3'. I do not mind whether the entries are centred or positioned to the left, but at the moment they are not the same and I cannot understand why. In addition to this in column 'Position 1', there are spaces between the 3 s.f. values and the \plusminus, have tried to get rid of this using ~ but to no avail. If you can help in any way I would be so, so grateful! Many thanks.

\documentclass[12pt, oneside]{article}   
\usepackage{geometry}                       
\geometry{a4paper}                                                  
\usepackage[parfill]{parskip}           
\usepackage{graphicx}               
\usepackage{amssymb}
\usepackage{titling}
\pagenumbering{arabic}                                  
\usepackage{wrapfig}
\usepackage[nottoc]{tocbibind}
\usepackage[round,authoryear]{natbib}
\usepackage{placeins}
\usepackage{gensymb}
\usepackage{array}
\usepackage{booktabs}
\usepackage{amsmath}
\graphicspath{ {paperfigures/} }
\usepackage{textcomp}
\usepackage[font={footnotesize}, margin=2cm]{caption}
\numberwithin{equation}{section}
\usepackage{tabularx}
\usepackage{siunitx}
\usepackage{floatrow}
\usepackage[font={scriptsize}, margin=0.5cm]{subfig}
\usepackage{multirow}

\begin{document}

\begin{table}[]
\scriptsize
\centering
\caption{Results for testing the directionality of the Light Diode, when detecting the light intensity at three locations in the room, at three different heights and four different orientations where 0\degree~indicates the diode is pointing directly upward, and each other degree value is taken from this.}
\label{tab:directional}
\sisetup{output-decimal-marker = {\cdot}}
\begin{tabular}{ll|S|S|S[table-format=-2.1]|}
\cline{3-5}
                                                      &                                            
&   \multicolumn{3}{c|}{\textbf{Mean Light Intensity at positions 
(mV)}}                                                            \\    
\hline
\multicolumn{1}{|l|}{\textbf{Vertical Position}}                   &     
\multicolumn{1}{c|}{\textbf{Orientation}} & \multicolumn{1}{c|}
{\textbf{Position 1}} & \multicolumn{1}{c|}{\textbf{Position 2}} & 
\multicolumn{1}{c|}{\textbf{Position 3}} \\ \hline
\multicolumn{1}{|l|}{\multirow{4}{*}{10 cm from ceiling}} & 0$\degree$                                
& 2.3 $\pm$ 2.0                       & 5.8 $\pm$ 2.0                       
& 8.2 $\pm$ 2.0                      \\ \cline{2-5} 
\multicolumn{1}{|l|}{}                                    & 45$\degree$                               
& 3.7 $\pm$ 2.0                       & 2.9 $\pm$ 2.0                       
& 26.1 $\pm$ 2.1                      \\ \cline{2-5} 
\multicolumn{1}{|l|}{}                                    & 90$\degree$                               
& 12.8 $\pm$ 2.0                      & 4.5 $\pm$ 2.0                          
& 13.6 $\pm$ 2.0                      \\ \cline{2-5} 
\multicolumn{1}{|l|}{}                                    & 
180$\degree$                              & 1.9 $\pm$ 2.0                       
& 4.0 $\pm$ 2.0                       & 3.0 $\pm$ 2.0                         
\\ \hline
\multicolumn{1}{|l|}{\multirow{4}{*}{Centre}}             & 0$\degree$                                
& 10.4 $\pm$ 2.0                      & 8.8 $\pm$ 2.0                          
& 11.4 $\pm$ 2.0                      \\ \cline{2-5} 
\multicolumn{1}{|l|}{}                                    & 45$\degree$                               
& 12.5 $\pm$ 2.0                      & 8.0 $\pm$ 2.0                       
& 7.2 $\pm$ 2.0                       \\ \cline{2-5} 
\multicolumn{1}{|l|}{}                                    & 90$\degree$                               
& 5.3 $\pm$ 2.0                       & 2.9 $\pm$ 2.0                       
& 5.1 $\pm$ 2.0                       \\ \cline{2-5} 
\multicolumn{1}{|l|}{}                                    & 
180$\degree$                              & 1.8 $\pm$ 2.0                         
& 1.4 $\pm$ 2.0                       & 1.2 $\pm$ 2.0                       
\\ \hline
\multicolumn{1}{|l|}{\multirow{4}{*}{10 cm from floor}}   & 0$\degree$                                
& 9.6 $\pm$ 2.0                       & 6.9 $\pm$ 2.0                       
& 11.0 $\pm$ 2.0                      \\ \cline{2-5} 
\multicolumn{1}{|l|}{}                                    & 45$\degree$                               
& 12.2 $\pm$ 2.0                      & 9.0 $\pm$ 2.0                       
& 3.5 $\pm$ 2.0                       \\ \cline{2-5} 
\multicolumn{1}{|l|}{}                                    & 90$\degree$                               
& 2.3 $\pm$ 2.0                       & 2.2 $\pm$ 2.0                       
& 1.5 $\pm$ 2.0                       \\ \cline{2-5} 
\multicolumn{1}{|l|}{}                                    & 
180$\degree$                              & 2.1 $\pm$ 2.0                       
& 1.6 $\pm$ 2.0                       & 0.9 $\pm$ 2.0                       
\\ \hline
\end{tabular}
\end{table}    
\end{document}  

Table in question

3

Probably you like to obtain something like this:

enter image description here

Your problem is consequence that \multicolumn{3}{c|}{...} is wider than columns widths which it span. So I enlarge their width with new formatting (see code). Beside this I clean up your code (which contain bunch of errors) all unnecessary \multicolumns and wrong coding of uncertainties.

\documentclass[12pt, oneside]{article}
\usepackage{geometry}
\geometry{a4paper}
%\usepackage[parfill]{parskip}
%\usepackage{graphicx}
%\usepackage{amssymb}
%\usepackage{titling}
%\pagenumbering{arabic}
%\usepackage{wrapfig}
%\usepackage[nottoc]{tocbibind}
%\usepackage[round,authoryear]{natbib}
%\usepackage{placeins}
%\usepackage{gensymb}
%\usepackage{amsmath}
%\graphicspath{ {paperfigures/} }
%\usepackage{textcomp}
\usepackage[font={footnotesize}, margin=2cm]{caption}
%\numberwithin{equation}{section}
\usepackage{siunitx}
%\usepackage{floatrow}
%\usepackage[font={scriptsize}, margin=0.5cm]{subfig}
\usepackage{array}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{tabularx}

\begin{document}

\begin{table}
    \scriptsize
    \centering
\caption{Results for testing the directionality of the Light Diode, when detecting the light intensity at three locations in the room, at three different heights and four different orientations where 0 indicates the diode is pointing directly upward, and each other degree value is taken from this.}
\label{tab:directional}
\sisetup{output-decimal-marker = {\cdot}}
\begin{tabular}{|l|S[table-format = 3]<{\si{\degree}}
             |*{3}{S[table-format = 4.1,
                     separate-uncertainty,
                     table-space-text-post={\quad},
                     table-figures-uncertainty=1]|}}
\cline{3-5}
\multicolumn{2}{c|}{} 
&   \multicolumn{3}{c|}{\textbf{Mean Light Intensity at positions
(mV)}}                                                            \\
\hline
\textbf{Vertical Position}
    &   \multicolumn{1}{c|}{\textbf{Orientation}}
        &   \textbf{Position 1}
            &   \textbf{Position 2}
                &   \textbf{Position 3}     \\ \hline
\multirow{4}{*}{10 cm from ceiling}
    & 0    & 2.3 \pm 2.0 & 5.8 \pm 2.0 & 8.2 \pm 2.0                   \\ \cline{2-5}
    & 45  & 3.7 \pm 2.0 & 2.9 \pm 2.0 & 26.1 \pm 2.1                      \\ \cline{2-5}
    & 90  & 12.8\pm 2.0 & 4.5 \pm 2.0 & 13.6 \pm 2.0                      \\ \cline{2-5}
    & 180 & 1.9 \pm 2.0 & 4.0 \pm 2.0 & 3.0 \pm 2.0 \\ \hline
\multirow{4}{*}{Centre}
    & 0   & 10.4\pm 2.0 & 8.8 \pm 2.0 & 11.4 \pm 2.0                      \\ \cline{2-5}
    & 45  & 12.5\pm 2.0 & 8.0 \pm 2.0 & 7.2 \pm 2.0                       \\ \cline{2-5}
    & 90  & 5.3 \pm 2.0 & 2.9 \pm 2.0 & 5.1 \pm 2.0                       \\ \cline{2-5}
    & 180 & 1.8 \pm 2.0 & 1.4 \pm 2.0 & 1.2 \pm 2.0 \\ \hline
\multirow{4}{*}{10 cm from floor}
    & 0   & 9.6 \pm 2.0 & 6.9 \pm 2.0 & 11.0 \pm 2.0                       \\ \cline{2-5}
    & 45  & 12.2\pm 2.0 & 9.0 \pm 2.0 & 3.5 \pm 2.0                       \\ \cline{2-5}
    & 90  & 2.3 \pm 2.0 & 2.2 \pm 2.0 & 1.5 \pm 2.0                       \\ \cline{2-5}
    & 180 & 2.1 \pm 2.0 & 1.6 \pm 2.0 & 0.9 \pm 2.0 \\ \hline
\end{tabular}
\end{table}
\end{document}

I also comment all packages which aren't relevat for this code.

3

I simplified your code, added some padding between rows thanks to the makecell package, and propose another, better-looking solution code, without vertical lines, using booktabs:

\documentclass[12pt, oneside]{article}
\usepackage{geometry}
\geometry{a4paper}
\usepackage{amssymb}
\usepackage{array}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage[font={footnotesize}, margin=2cm]{caption}
\usepackage{siunitx}
\usepackage{multirow, cellspace}
\setlength\cellspacetoplimit{3pt}
\setlength\cellspacebottomlimit{3pt}

\begin{document}

\begin{table}[!htb]
  \scriptsize
  \centering
  \caption{Results for testing the directionality of the Light Diode, when detecting the light intensity at three locations in the room, at three different heights and four different orientations where \SI{0}{\degree}~indicates the diode is pointing directly upward, and each other degree value is taken from this.}
  \label{tab:directional}
  \sisetup{ table-number-alignment=center, output-decimal-marker={ · },separate-uncertainty, table-format=2.1(2), mode=math}
  \begin{tabular}{|l|Cl|*{3}{S|}}
    \cline{3-5}
    \multicolumn{2}{c|}{}& \multicolumn{3}{Cc|}{\textbf{Mean Light Intensity at positions
    (mV)}} \\
    \hline
    {\textbf{Vertical Position}} &
    {\textbf{Orientation}} & {\textbf{Position 1}} & {\textbf{Position 2}} &{\textbf{Position 3}} \\%
    \hline
    \multirow{4}{*}[-2pt]{10 cm from ceiling} & \SI{0}{\degree} & 2.3 ±2 & 5.8 ±2 & 8.2 ±2 \\%
    \cline{2-5}
                                              & \SI{45}{\degree} & 3.7 ±2 & 2.9 ±2 & 26.1 ±2.1 \\%
    \cline{2-5}
                                              & \SI{90}{\degree} & 12.8 ±2 & 4.5 ±2 & 13.6 ±2 \\ %
    \cline{2-5}
                                              & \SI{180}{\degree} & 1.9 ±2 & 4.0 ±2 & 3.0 ±2 \\%
    \hline
    \multirow{4}{*}[-2pt]{Centre} & \SI{0}{\degree} & 10.4 ±2 & 8.8 ±2 & 11.4 \pm2 \\%
    \cline{2-5}
                                              & \SI{45}{\degree} & 12.5 ±2 & 8.0 ±2 & 7.2 ±2 \\%
    \cline{2-5}
                                              & \SI{90}{\degree} & 5.3 ±2 & 2.9 ±2 & 5.1 ±2 \\%
    \cline{2-5}
                                              & \SI{180}{\degree} & 1.8 ±2 & 1.4 ±2 & 1.2 ±2 \\%
    \hline
    \multirow{4}{*}[-2pt]{10 cm from floor} & \SI{0}{\degree}
    & 9.6 ±2 & 6.9 ±2 & 11.0 ±2 \\%
    \cline{2-5}
                                              & \SI{45}{\degree} & 12.2 ±2 & 9.0 ±2 & 3.5 ±2 \\%
    \cline{2-5}
                                              & \SI{90}{\degree} & 2.3 ±2 & 2.2 ±2 & 1.5 ±2 \\%
    \cline{2-5}
                                              & \SI{180}{\degree} & 2.1 ±2 & 1.6 ±2 & 0.9 ±2 \\%
    \hline
  \end{tabular} \end{table}

  \begin{table}[!htb]
    \scriptsize
    \centering
    \caption{Results for testing the directionality of the Light Diode, when detecting the light intensity at three locations in the room, at three different heights and four different orientations where \SI{0}{\degree}~indicates the diode is pointing directly upward, and each other degree value is taken from this.}
    \label{tab:directional}
    \sisetup{ table-number-alignment=center, output-decimal-marker={ · },separate-uncertainty, table-format=2.1(2), mode=math}
    \begin{tabular}{ll*{3}{S}}
      \multicolumn{2}{c}{}& \multicolumn{3}{c}{\textbf{Mean Light Intensity at positions (mV)}} \\
      \addlinespace[\aboverulesep]%
      \toprule
      \textbf{Vertical Position} & \textbf{Orientation} & {\textbf{Position 1}} & {\textbf{Position 2}} & {\textbf{Position 3}} \\%
      \midrule
      \multirow{4}{*}[-1.5\defaultaddspace]{10 cm from ceiling} & \SI{0}{\degree} & 2.3 ±2 & 5.8 ±2 & 8.2 ±2 \\%
      \addlinespace
                                                                & \SI{45}{\degree} & 3.7 ±2 & 2.9 ±2 & 26.1 ±2.1 \\%
      \addlinespace
                                                                & \SI{90}{\degree} & 12.8 ±2 & 4.5 ±2 & 13.6 ±2 \\ %
      \addlinespace
                                                                & \SI{180}{\degree} & 1.9 ±2 & 4.0 ±2 & 3.0 ±2 \\%
      \cmidrule(lr){1-5}
      \multirow{4}{*}[-1.5\defaultaddspace]{Centre} & \SI{0}{\degree} & 10.4 ±2 & 8.8 ±2 & 11.4 \pm2 \\%
      \addlinespace
                                                                & \SI{45}{\degree} & 12.5 ±2 & 8.0 ±2 & 7.2 ±2 \\%
      \addlinespace
                                                                & \SI{90}{\degree} & 5.3 ±2 & 2.9 ±2 & 5.1 ±2 \\%
      \addlinespace
                                                                & \SI{180}{\degree} & 1.8 ±2 & 1.4 ±2 & 1.2 ±2 \\%
      \cmidrule(lr){1-5}
      \multirow{4}{*}[-1.5\defaultaddspace]{10 cm from floor} & \SI{0}{\degree}
      & 9.6 ±2 & 6.9 ±2 & 11.0 ±2 \\%
      \addlinespace
                                                                & \SI{45}{\degree} & 12.2 ±2 & 9.0 ±2 & 3.5 ±2 \\%
      \addlinespace
                                                                & \SI{90}{\degree} & 2.3 ±2 & 2.2 ±2 & 1.5 ±2 \\%
      \addlinespace
                                                                & \SI{180}{\degree} & 2.1 ±2 & 1.6 ±2 & 0.9 ±2 \\%
      \bottomrule
    \end{tabular} \end{table}

\end{document} 

enter image description here

0

(This isn't quite complete -- needs work to align decimals between rows)

The actual answer is relatively simple, but you've got a ton of stuff cluttering up your example, making it more difficult for you (and possibly others) to isolate the problem.

To make a MWE, first make a copy of your document. Comment out or remove chapters, sections, paragraphs, packages, and parts of the table or other core content that have nothing to do with your problem. You know they have nothing to do with the problem if you can comment them out, and the document still behaves the same.

Doing this, your core MWE that still shows your problem is

\documentclass{article}
\usepackage{siunitx}

\begin{document}

\begin{table}[]
\begin{tabular}{llSSS[table-format=-2.1]}
label & 90 & 12.8 $\pm$ 2.0 & 4.5 $\pm$ 2.0 & 13.6 $\pm$ 2.0 \\
\end{tabular}
\end{table}
\end{document}

enter image description here

This makes it much easier to recognize that the [table-format=-2.1] is applied onto the last column, which has no errors. Applying the same format to the other 2 columns of data (that is, \begin{tabular}{llS[table-format=-2.1]S[table-format=-2.1]S[table-format=-2.1]}) yields

enter image description here

which fixes one spacing problem, and introduces another (the S columns are too narrow). Adding headers {Heading 1} & {Heading 2} & {Heading 3} & {Heading 4} & {Heading 5} doesn't really resolve anything:

enter image description here

but if you let siunitx use its \num macro (p. 6 of the current documentation) and its separate-uncertainties option (p. 29) to print your values and uncertainties, things work out better, and it's less work for you:

\documentclass{article}
\usepackage{siunitx}

\begin{document}

\begin{table}
\sisetup{table-format=-2.1, separate-uncertainty}
\begin{tabular}{llSSS}
{Heading 1} & {Heading 2} & {Heading 3} & {Heading 4} & {Heading 5} \\
label & 90 & \num{12.8 +- 2} & \num{4.5 \pm 2.0} & \num{13.6 \pm 2.0} \\
\end{tabular}
\end{table}
\end{document}

enter image description here

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.