5
{
\renewcommand{\arraystretch}{1.3}
\begin{table}
\begin{tabular}{lc}
\hline\hline\noalign{\smallskip}
F&                      R         \\
\noalign{\smallskip}\hline\noalign{\smallskip}

42.34 \pd 0.16 & 42.34 \pd 0.16          \\
424.34 \pd 0.16          &   5542.34 \pd 50.16  \\
\noalign{\smallskip}\hline\noalign{\smallskip}
21.9            &   20.8            \\
9.1             &   8.7             \\

\noalign{\smallskip}\hline\noalign{\smallskip}
\end{tabular}
\end{table}
}

The code after your help:

{
\renewcommand{\arraystretch}{1.3}
\begin{table*}
\caption[]{Solution in \phoebe for different input photometry files, based on photometric data sets and Gaussian RVs for
the primary}\label{PHOEB}
\begin{flushleft}
\sisetup{separate-uncertainty}
\begin{tabular}{l*{6}S[table-format = 3.3(3)]}
\hline\hline\noalign{\smallskip}
Data&                       B.R         &   B.B         &   A            &  B            &  K + K    &  K + L +\\&&&&&&+ S \\
\noalign{\smallskip}\hline\noalign{\smallskip}

Co $ \chi^2$   &    3.758           &   1.721           &   76.945          &   1.008           &   11.389          &   4.067               \\
$b$                  &   42.34 \pd 0.16  &  41.63 \pd 0.37  &   41.56 \pd 0.47  &   40.71 \pd 0.21  &   41.91 \pd 0.18  &   41.81 \pd 0.43      \\
\noalign{\smallskip}\hline\noalign{\smallskip}
A           &   21.9            &   20.8            &   20.7            &   19.4            &   21.1            &   21.1                \\
B           &   9.1             &   8.7             &   8.6             &   8.1             &   8.8             &   8.8                 \\
\noalign{\smallskip}\hline\noalign{\smallskip}
\end{tabular}
The rms errors of the last two quoted digits are given in brackets after the respective value. 
\end{flushleft}
\end{table*}
}
1
  • 1
    Please tell us how \pd is defined. Is it maybe just a mis-spelling of \pm?
    – Mico
    Sep 2, 2019 at 10:16

3 Answers 3

4

Using siunitx:

\documentclass{article}
\usepackage{siunitx}
\begin{document}
{
\renewcommand{\arraystretch}{1.3}
\begin{table}
\sisetup{separate-uncertainty}
\begin{tabular}{S[table-format = 3.2(3)]S[table-format = 4.2(4)]}
\hline\hline\noalign{\smallskip}
F&                      R         \\
\noalign{\smallskip}\hline\noalign{\smallskip}

42.34 \pm 0.16 & 42.34 \pm 0.16          \\
424.34 \pm 0.16          &   5542.34 \pm 50.16  \\
\noalign{\smallskip}\hline\noalign{\smallskip}
21.9            &   20.8            \\
9.1             &   8.7             \\

\noalign{\smallskip}\hline\noalign{\smallskip}
\end{tabular}
\end{table}
}
\end{document}

I took a liberty and add image of table produced with above code:

enter image description here

3
  • Thank you and what does this error means? siunitx error: "invalid-number"!!! Sep 2, 2019 at 10:38
  • The example runs as-is: please say what you've changed
    – Joseph Wright
    Sep 2, 2019 at 10:43
  • I edded the code after your help to my question Sep 2, 2019 at 13:06
3

I would also use siunitx and exploit its option separate-uncertainty:

\documentclass{article}
\usepackage{siunitx}

\begin{document}
    \begin{table}
\renewcommand{\arraystretch}{1.3}
\sisetup{separate-uncertainty,
         group-four-digits}
\begin{tabular}{S[table-format = 3.2(3)]
                S[table-format = 4.2(4)]}
\hline\hline
F           & R                     \\
\hline
 42.34(16)  &   42.34(16)           \\
424.34(16)  & 5542.34(5016)         \\
\hline
21.9        &   20.8                \\
 9.1        &    8.7                \\
\hline
\end{tabular}
    \end{table}
\end{document}

which gives:

enter image description here

Addendum

It seems that you looking for something like this:

enter image description here

Above table is composed with two successive tables and manual tweaks for position of the column header. From comment of Barbara Beeton follows that this is somewhere already settled, but I didn't find this.

\documentclass{article}
\usepackage{siunitx}

\begin{document}
    \begin{table}
\renewcommand{\arraystretch}{1.3}
\sisetup{separate-uncertainty,
         table-column-width=6em}
\begin{tabular}{S[table-format = 3.2(3)]
                S[table-format = 4.2(4)]}
    \hline\hline
\hphantom{XX}F
            & \hphantom{XXx}R        \\
\hline
 42.34(16)  &   42.34(16)           \\
424.34(16)  & 5542.34(5016)         \\
    \hline
\end{tabular}\\
\begin{tabular}{S[table-format = 4.2]
                S[table-format = 5.2]}
21.9        &   20.8                \\
 9.1        &    8.7                \\
    \hline
\end{tabular}
    \end{table}
\end{document}
16
  • Is it possible to center it? I mean that \pm and decimal point will be under the R? Sep 2, 2019 at 12:55
  • What means the number in () please? table-format = 3.2(3) Sep 2, 2019 at 12:58
  • 1
    number of digits present uncertainty. i.e part of number after pm symbol. For more details please read siunitx documentation.
    – Zarko
    Sep 2, 2019 at 13:09
  • 1
    @LukášAltman, both can't be centered at same time.
    – Zarko
    Sep 2, 2019 at 13:38
  • 1
    This may already have been settled, but I think that the wish is for the "F" and "R" in the column headings to be positioned directly above the \pm. Sep 2, 2019 at 19:51
3

This may alternatively be done fairly simply using the dcolumn package, and then some spacing adjustments. The new column type defined here centers on the + but prints \pm:

\documentclass[11pt]{article}

\usepackage{dcolumn}

\begin{document}

\renewcommand{\arraystretch}{1.3}
\begin{table}
\newcolumntype{e}[1]{D{+}{\,\pm\,}{#1}} % see dcolumn documentation, page 2

\begin{tabular}{e{6.4}e{7.5}}
\hline\hline\noalign{\smallskip}
\multicolumn{1}{c}{F} &   \multicolumn{1}{c}{R} \\
\noalign{\smallskip}\hline\noalign{\smallskip}
42.34+0.16  &   42.34+0.16   \\
424.34+0.16 & 5542.34+50.16  \\
\noalign{\smallskip}\hline\noalign{\smallskip}
21.9            &   20.8      \\
9.1             &   8.7       \\
\noalign{\smallskip}\hline\noalign{\smallskip}
\end{tabular}
\end{table}

\end{document}

enter image description here

Some of the prior comments requested further centering of the heading and the decimal in the next rows. To cover the headings, one way is to make numbers in the newcolumn type symmetric, so that the \pm is in the center of the column. To deal with the decimal numbers below, we can add a phantom character to bring the decimal to the center of the column.

\renewcommand{\arraystretch}{1.3}
\begin{table}
\newcolumntype{e}[1]{D{+}{\,\pm\,}{#1}} % see dcolumn documentation, page 2

\begin{tabular}{e{6.6}e{7.7}} % These only need to be 6.4 and 7.5, but making the 6.6 and 7.7 (symmetric) centers F and R on pm.
\hline\hline\noalign{\smallskip}
\multicolumn{1}{c}{F} &   \multicolumn{1}{c}{R} \\
\noalign{\smallskip}\hline\noalign{\smallskip}
42.34+0.16  &   42.34+0.16   \\
424.34+0.16 & 5542.34+50.16  \\
\noalign{\smallskip}\hline\noalign{\smallskip}
\multicolumn{1}{c}{21.9\phantom{9}}  &   \multicolumn{1}{c}{20.8\phantom{9}} \\ % <== add phantom character to make the decimal centered
\multicolumn{1}{c}{9.1}              &  \multicolumn{1}{c}{8.7}              \\% <== add phantom character to make the decimal centered
\noalign{\smallskip}\hline\noalign{\smallskip}
\end{tabular}
\end{table}

enter image description here

3
  • Thank you very much, it's great solution Sep 3, 2019 at 19:07
  • Glad that it worked well for you!
    – John
    Sep 3, 2019 at 21:19
  • One of a nice reply...
    – MadyYuvi
    Jan 11, 2022 at 8:27

You must log in to answer this question.

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