0

I am trying to format the following table so that it is aligned by the first dot of each number. However, since it has multiple types of data (numeric and non-numeric), the solutions provided in questions like Table formatting, Align numbers and separated uncertainties in tables with S columns, and Align along dot in tables render unsuitable for my problem.

Could anybody guide me on how to adapt the provided solutions in the quoted questions or provide a new one? Thank you.

\documentclass[12pt]{article}
\begin{document}
\begin{table}
\begin{tabular}{lrr}
  \hline
Variables & LC-MIXL $(\delta=0.5)$ & LC-MIXL $(\delta=1)$ \\ 
  \hline
$x_{1} (\mu_{1})$ &     0.982( 0.038)*** &     1.900(0.065)*** \\ 
  $x_{1} (\mu_{2})$ &     2.106( 0.095)*** &     0.987(0.029)*** \\ 
  $x_{1} (\mu_{3})$ &     1.500( 0.052)*** &     3.116(0.119)*** \\ \hline
  $x_{1} (\sigma_{1}) $ &    -0.475( 0.032)*** &    -0.412(0.090)*** \\ 
  $x_{1} (\sigma_{2}) $ &    -0.500( 0.209)*   &    -0.476(0.031)*** \\ 
  $x_{1} (\sigma_{3}) $ &     0.451( 0.079)*** &    -0.362(0.164)*   \\\hline 
  $\lambda_{2}$ & -1256.463( 6.938)*** &   713.931(0.109)*** \\ 
  $Z_1 (\gamma_{2})$ &  1393.016(10.198)*** & -1363.373(0.170)*** \\ 
  $Z_2 (\gamma_{2})$ &   548.092(49.471)*** &    90.991(1.333)*** \\ 
  $Z_3 (\gamma_{2})$ &    -0.065( 2.693)    &   -39.020(3.230)*** \\ 
  $Z_4 (\gamma_{2})$ &    96.515(71.407)    &   -39.031(2.010)*** \\ 
  $Z_5 (\gamma_{2})$ &   -89.312(12.438)*** &    65.439(3.031)*** \\ \hline
  N & 15000 & 15000 \\ 
  LL & -10337.07 & 9443.21 \\ 
  Num.Params & 30 & 30 \\ 
  AIC & 20962.61 & 19174.89 \\ 
  BIC & 20734.13 & 18946.41 \\ \hline
  $\bar{\pi}_{1}$ & \%54.17 & \%24.17 \\ 
$\bar{\pi}_{2}$ & \%19.05 & \%54.27 \\ 
$\bar{\pi}_{3}$ & \%26.78 & \%21.57 \\ 
   \hline\hline
\end{tabular}
\end{table}
\end{document}

enter image description here

2

3 Answers 3

1

Since you keep the same number of decimal places, you could simply apply right alignment for all numbers. In special cases add extra space to the right via \hphantom{} if you need to mix integers with non-integers; the macro does not typeset anything but adds white space equal to its content (See the example).

I also split numbers and uncertainties in two separate columns; enclosed the tabular within threeparttable environment, which lets you add notes at the bottom the table; and finally added custom rules define by booktabs for a better presentation.

enter image description here

\documentclass[12pt]{article}
\usepackage{array}
\usepackage{booktabs}
\usepackage{threeparttable}

\begin{document}
\begin{table}
  \centering
  \begin{threeparttable}
    \caption{Example}\label{tab:example}
    \begin{tabular}{
        >{$}l<{$} r@{\;}r @{\hspace{2em}}  r@{\;}r @{\hspace{1.5em}}
      }
      \toprule
      \textup{Variables} & \multicolumn{4}{c}{LC-MIXL} \\
      \cmidrule(lr){2-5}
      & \multicolumn{2}{c}{\((\delta = 0.5)\)} & \multicolumn{2}{c}{\((\delta = 1.0)\)}       \\
      \midrule
      x_{1} (\mu_{1})     &     0.982 & (0.038)\tnote{***}   &     1.900 & (0.065)\tnote{***} \\
      x_{1} (\mu_{2})     &     2.106 & (0.095)\tnote{***}   &     0.987 & (0.029)\tnote{***} \\
      x_{1} (\mu_{3})     &     1.500 & (0.052)\tnote{***}   &     3.116 & (0.119)\tnote{***} \\
      \midrule
      x_{1} (\sigma_{1})  &    -0.475 & (0.032)\tnote{***}   &    -0.412 & (0.090)\tnote{***} \\
      x_{1} (\sigma_{2})  &    -0.500 & (0.209)\tnote{*}     &    -0.476 & (0.031)\tnote{***} \\
      x_{1} (\sigma_{3})  &     0.451 & (0.079)\tnote{***}   &    -0.362 & (0.164)\tnote{*}   \\
      \midrule
      \lambda_{2}         & -1256.463 & (6.938)\tnote{***}   &   713.931 & (0.109)\tnote{***} \\
      Z_1 (\gamma_{2})    &  1393.016 & (10.198)\tnote{***}  & -1363.373 & (0.170)\tnote{***} \\
      Z_2 (\gamma_{2})    &   548.092 & (49.471)\tnote{***}  &    90.991 & (1.333)\tnote{***} \\
      Z_3 (\gamma_{2})    &    -0.065 & (2.693)              &   -39.020 & (3.230)\tnote{***} \\
      Z_4 (\gamma_{2})    &    96.515 & (71.407)             &   -39.031 & (2.010)\tnote{***} \\
      Z_5 (\gamma_{2})    &   -89.312 & (12.438)\tnote{***}  &    65.439 & (3.031)\tnote{***} \\
      \midrule
      \textup{N}          & 15000\hphantom{.00} &            & 15000\hphantom{.00} & \\
      \textup{LL}         & -10337.07 &                      & 9443.21   & \\
      \textup{Num.Params} & 30\hphantom{.00}    &            & 30\hphantom{.00} & \\
      \textup{AIC}        & 20962.61            &            & 19174.89  & \\
      \textup{BIC}        & 20734.13            &            & 18946.41  & \\
      \midrule
      \bar{\pi}_{1}       & \%54.17             &            & \%24.17   & \\
      \bar{\pi}_{2}       & \%19.05             &            & \%54.27   & \\
      \bar{\pi}_{3}       & \%26.78             &            & \%21.57   & \\
      \bottomrule\bottomrule
    \end{tabular}
    \begin{tabular}{>{$}l<{$}@{\;}l}
      ^{*}   & Note for one star \\
      ^{***} & Note for three stars
    \end{tabular}
  \end{threeparttable}
\end{table}
\end{document}
1

You can use \begin{tabular}{lr@{.}lr@{.}l} and replace all the first dot by &

\begin{document}
\begin{table}
\begin{tabular}{lr@{.}lr@{.}l}
  \hline
Variables & LC-MIXL & $(\delta=0.5)$ & LC-MIXL & $(\delta=1)$ \\ 
  \hline
$x_{1} (\mu_{1})      $ &     0&982( 0.038)*** &     1&900(0.065)*** \\ 
  $x_{1} (\mu_{2})    $ &     2&106( 0.095)*** &     0&987(0.029)*** \\ 
  $x_{1} (\mu_{3})    $ &     1&500( 0.052)*** &     3&116(0.119)*** \\ \hline
  $x_{1} (\sigma_{1}) $ &    -0&475( 0.032)*** &    -0&412(0.090)*** \\ 
  $x_{1} (\sigma_{2}) $ &    -0&500( 0.209)*   &    -0&476(0.031)*** \\ 
  $x_{1} (\sigma_{3}) $ &     0&451( 0.079)*** &    -0&362(0.164)*   \\\hline 
  $\lambda_{2}        $ & -1256&463( 6.938)*** &   713&931(0.109)*** \\ 
  $Z_1 (\gamma_{2})   $ &  1393&016(10.198)*** & -1363&373(0.170)*** \\ 
  $Z_2 (\gamma_{2})   $ &   548&092(49.471)*** &    90&991(1.333)*** \\ 
  $Z_3 (\gamma_{2})   $ &    -0&065( 2.693)    &   -39&020(3.230)*** \\ 
  $Z_4 (\gamma_{2})   $ &    96&515(71.407)    &   -39&031(2.010)*** \\ 
  $Z_5 (\gamma_{2})   $ &   -89&312(12.438)*** &    65&439(3.031)*** \\ \hline
  N                     & 15000&0              & 15000&0 \\ 
  LL                    & -10337&07            & 9443&21 \\ 
  Num.Params            & 30&0                 & 30&0 \\ 
  AIC                   & 20962&61             & 19174&89 \\ 
  BIC                   & 20734&13             & 18946&41 \\ \hline
  $\bar{\pi}_{1}$       & \%54&17              & \%24&17 \\ 
  $\bar{\pi}_{2}$       & \%19&05              & \%54&27 \\ 
  $\bar{\pi}_{3}$       & \%26&78              & \%21&57 \\ 
   \hline\hline
\end{tabular}
\end{table}
\end{document}

Will produce

enter image description here

2
  • That's amazing, @YannisSauzeau. However, is there any trick to not having to add a decimal for integer numbers so that I can avoid to mask 15000 as 15000.0? Thanks Commented Aug 31, 2022 at 15:12
  • Unfortunately with this method you can't have 15000 without the dot, but you can have 15000. without the 0 after the dot if you prefer Commented Aug 31, 2022 at 15:13
1

You may want to look at siunitx package that provides S column type that does exactly what you're after.

\documentclass[12pt]{article}
\usepackage{siunitx}
\begin{document}
\begin{table}
\begin{tabular}{lSS}
  \hline
Variables & {LC-MIXL $(\delta=0.5)$} & {LC-MIXL $(\delta=1)$} \\ 
  \hline
$x_{1} (\mu_{1})$ &     0.982( 0.038)*** &     1.900(0.065)*** \\ 
  $x_{1} (\mu_{2})$ &     2.106( 0.095)*** &     0.987(0.029)*** \\ 
  $x_{1} (\mu_{3})$ &     1.500( 0.052)*** &     3.116(0.119)*** \\ \hline
  $x_{1} (\sigma_{1}) $ &    -0.475( 0.032)*** &    -0.412(0.090)*** \\ 
  $x_{1} (\sigma_{2}) $ &    -0.500( 0.209)*   &    -0.476(0.031)*** \\ 
  $x_{1} (\sigma_{3}) $ &     0.451( 0.079)*** &    -0.362(0.164)*   \\\hline 
  $\lambda_{2}$ & -1256.463( 6.938)*** &   713.931(0.109)*** \\ 
  $Z_1 (\gamma_{2})$ &  1393.016(10.198)*** & -1363.373(0.170)*** \\ 
  $Z_2 (\gamma_{2})$ &   548.092(49.471)*** &    90.991(1.333)*** \\ 
  $Z_3 (\gamma_{2})$ &    -0.065( 2.693)    &   -39.020(3.230)*** \\ 
  $Z_4 (\gamma_{2})$ &    96.515(71.407)    &   -39.031(2.010)*** \\ 
  $Z_5 (\gamma_{2})$ &   -89.312(12.438)*** &    65.439(3.031)*** \\ \hline
  N & 15000 & 15000 \\ 
  LL & -10337.07 & 9443.21 \\ 
  Num.Params & 30 & 30 \\ 
  AIC & 20962.61 & 19174.89 \\ 
  BIC & 20734.13 & 18946.41 \\ \hline
  $\bar{\pi}_{1}$ & \%54.17 & \%24.17 \\ 
$\bar{\pi}_{2}$ & \%19.05 & \%54.27 \\ 
$\bar{\pi}_{3}$ & \%26.78 & \%21.57 \\ 
   \hline\hline
\end{tabular}
\end{table}
\end{document}

enter image description here

You must log in to answer this question.

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