0
\documentclass[12pt]{article}
\usepackage[portuguese]{babel}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{subfig}
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs}
\usepackage[nodisplayskipstretch]{setspace}
\usepackage{amssymb}
\usepackage{setspace}
\usepackage[section]{placeins}
\usepackage{dcolumn}
\usepackage{siunitx,booktabs}
\usepackage{url}
\usepackage{float}
\usepackage{subcaption}
\usepackage{tabularx}
\usepackage{adjustbox}
\usepackage{rotating}
\usepackage{lipsum}
\usepackage{amsmath}
\usepackage{geometry}
\usepackage[tableposition=top]{caption}
\usepackage{babel}
\usepackage[style=authoryear]{biblatex}
\geometry{
a4paper,
total={140mm,190mm},
}
\usepackage[T1]{fontenc}

\newcolumntype{d}[1]{D{.}{.}{#1}}

\begin{document} 
   \begin{table}[!htb]
    \centering

    \caption{Model results}
    \begin{adjustbox}{max width=\textwidth}
    \begin{tabular}{ld{2.4}d{2.4}d{2.4}d{2.4}d{2.4}d{2.4}}
    \hline
    Link &  \multicolumn{1}{c}{Logit} &  & \multicolumn{1}{c}{Probit} &  & \multicolumn{1}{c}{Cloglog} &\\
    \hline
    Parameter &Mean &Sd & Mean & Sd & Mean &Sd  \\
    \hline
    $\beta_0$ &-0,6229 &0,2370 &-0,3853 &0,1425 &-0,8401 &0,1931  \\
    $\beta_1$ &-0,0123 &0,0033 &-0,0072 &0,0019&-0,0107 &0,0027  \\
    $\beta_2$  &0,1184 &0,0379 &0,0688 &0,0234 &0,1027 &0,0314 \\
    $\phi$  &33,0987 &7,6123 &32,4051 &7,6602 &33,8460 &8,0493 \\
    \hline
    Credible Interval & & & & & &\\
    \hline
    Parameter &  2.5\% & 97.5\% & 2.5\% & 97.5\% & 2.5\% & 97.5\%  \\
    \hline
    $\beta_0$ &-1,1034 &-0,1601 &-0,6631 &-0,1042 &-1,2247 &-0,4598 \\
    $\beta_1$  &-0,0186 &-0,0056 &-0,0112 &-0,0034 &-0,0159 &-0,0050 \\
    $\beta_2$  & 0,0443 &0,1933 &0,0219 &0,1134 & 0,0415&0,1627 \\
    $\phi$  &19,6661 &49,6969 & 19,0686 &49,1156 &20,1797&51,8046 \\
    \hline
    \end{tabular}
    \end{adjustbox}
    \end{table}
\end{document}

The values in line of Parameter 2.5%, 97.5%, etc are not aligned with Mean's and Sd's.

  • Would you please post a full compilable code, so we can test? Align with what? – Bernard Apr 29 '17 at 0:59
  • @Bernard I think I put a compilable code now. I want to align the values 2.5% , 97.5%, 2.5%, .... with Mean's and Sd's – Roland Apr 29 '17 at 1:11
  • Off-topic as it's a natural-language issue, not a LaTeX issue: Instead of writing "Credible Interval", consider writing "Confidence Interval". – Mico Apr 29 '17 at 9:17
1

Here are two solutions, with siunitx (strange things seem to happen with dcolumn). In the second solution, I used booktabs, without any vertical line, to have a more professional look. In both, I removed the adjustwidth environment, which shouldn't be used with tables. Also, note packages subfig andsubcaption` are incompatible. Prefer the latter.

\documentclass[12pt, portuguese]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage[flushleft]{threeparttable}
\usepackage[nodisplayskipstretch]{setspace}
\usepackage{amssymb}
\usepackage{setspace}
\usepackage[section]{placeins}
\usepackage{siunitx,booktabs}
\usepackage{url}
\usepackage{float}
\usepackage{tabularx}
\usepackage{adjustbox}
\usepackage{rotating}
\usepackage{lipsum}
\usepackage{geometry}
\usepackage[tableposition=top]{caption}
\usepackage{subcaption}
\usepackage[style=authoryear]{biblatex}
\geometry{
a4paper,
total={140mm,190mm},
}

\newcolumntype{d}[1]{D{.}{.}{#1}}

\begin{document}

   \begin{table}[!htb]
    \centering
    \caption{Model results}
\sisetup{table-format = -1.4, table-number-alignment=center}
    \begin{tabular}{l|*{6}{S|}}
    \hline
    Link & \multicolumn{2}{c|}{Logit} &\multicolumn{2}{c|}{Probit} & \multicolumn{2}{c|}{Cloglog}\\
    \hline
    Parameter &{Mean} &{Sd} & {Mean} & {Sd }& {Mean} & {Sd} \\
    \hline
    $\beta_0$ &-0,6229 &0,2370 &-0,3853 &0,1425 &-0,8401 &0,1931 \\
    $\beta_1$ &-0,0123 &0,0033 &-0,0072 &0,0019&-0,0107 &0,0027 \\
    $\beta_2$ &0,1184 &0,0379 &0,0688 &0,0234 &0,1027 &0,0314 \\
    $\phi$ &33,0987 &7,6123 &32,4051 &7,6602 &33,8460 &8,0493 \\
    \hline
    Credible Interval & & & & & &\\
    \hline
    Parameter & \SI{2.5}{\%} & \SI{97.5}{\%} & \SI{2.5}{\%} & \SI{97.5}{\%} & \SI{2.5}{\%} & \SI{97.5}{\%} \\
    \hline
    $\beta_0$ &-1,1034 &-0,1601 &-0,6631 &-0,1042 &-1,2247 &-0,4598 \\
    $\beta_1$ &-0,0186 &-0,0056 &-0,0112 &-0,0034 &-0,0159 &-0,0050 \\
    $\beta_2$ & 0,0443 &0,1933 &0,0219 &0,1134 & 0,0415&0,1627 \\
    $\phi$ &19,6661 &49,6969 & 19,0686 &49,1156 &20,1797&51,8046 \\
    \hline
    \end{tabular}
    \end{table}

   \begin{table}[!htb]
    \centering
    \caption{Model results}
\sisetup{table-format = -1.4, table-number-alignment=center}
    \begin{tabular}{l*{6}{S}}
    \toprule
    Link & \multicolumn{2}{c}{Logit} &\multicolumn{2}{c}{Probit} & \multicolumn{2}{c}{Cloglog}\\
    \cmidrule{1-7}
    Parameter &{Mean} &{Sd} & {Mean} & {Sd }& {Mean} & {Sd} \\
    \midrule
    $\beta_0$ &-0,6229 &0,2370 &-0,3853 &0,1425 &-0,8401 &0,1931 \\
    $\beta_1$ &-0,0123 &0,0033 &-0,0072 &0,0019&-0,0107 &0,0027 \\
    $\beta_2$ &0,1184 &0,0379 &0,0688 &0,0234 &0,1027 &0,0314 \\
    $\phi$ &33,0987 &7,6123 &32,4051 &7,6602 &33,8460 &8,0493 \\
    \midrule
    Credible Interval \\
    \cmidrule{1-7}
    Parameter & \SI{2.5}{\%} & \SI{97.5}{\%} & \SI{2.5}{\%} & \SI{97.5}{\%} & \SI{2.5}{\%} & \SI{97.5}{\%} \\
    \midrule
    $\beta_0$ &-1,1034 &-0,1601 &-0,6631 &-0,1042 &-1,2247 &-0,4598 \\
    $\beta_1$ &-0,0186 &-0,0056 &-0,0112 &-0,0034 &-0,0159 &-0,0050 \\
    $\beta_2$ & 0,0443 &0,1933 &0,0219 &0,1134 & 0,0415&0,1627 \\
    $\phi$ &19,6661 &49,6969 & 19,0686 &49,1156 &20,1797&51,8046 \\%
    \bottomrule
    \end{tabular}
    \end{table}

\end{document} 

enter image description here

1

Here's a solution that keeps using the dcolumn package and its d column type.

Since you appear to be using , (comma) as the output decimal marker, I suggest replacing \newcolumntype{d}[1]{D{.}{.}{#1}} with \newcolumntype{d}[1]{D{,}{,}{#1}}. Since you're using the booktabs package anyway, I've also reorganized the look of the table to give it a more open look: Note the absence of vertical lines and the presence of fewer, but better spaced horizontal lines.

enter image description here

\documentclass[12pt]{article}
% I've stripped down the preamble to the bare mininum
\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{dcolumn,booktabs,geometry}
\geometry{a4paper,total={140mm,190mm}}
\usepackage[skip=0.333\baselineskip]{caption}

\newcolumntype{d}[1]{D{,}{,}{#1}} $ commas, not periods
\newcommand\mr[1]{\multicolumn{1}{r}{#1}} % handy shortcut macro

\begin{document} 
\begin{table}[!htb]
    \centering
    \caption{Model results}
    \begin{tabular}{@{}l*{6}{d{2.4}}@{}}
    \toprule
    Link &  \multicolumn{2}{c}{Logit} & \multicolumn{2}{c}{Probit} & \multicolumn{2}{c}{Cloglog} \\
    \cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(l){6-7}
    Parameter &\mr{Mean} &\mr{Sd} &\mr{Mean} &\mr{Sd} &\mr{Mean} &\multicolumn{1}{r@{}}{Sd}   \\
    \midrule
    $\beta_0$ &-0,6229 &0,2370 &-0,3853 &0,1425 &-0,8401 &0,1931  \\
    $\beta_1$ &-0,0123 &0,0033 &-0,0072 &0,0019&-0,0107 &0,0027  \\
    $\beta_2$  &0,1184 &0,0379 &0,0688 &0,0234 &0,1027 &0,0314 \\
    $\phi$  &33,0987 &7,6123 &32,4051 &7,6602 &33,8460 &8,0493 \\

    \addlinespace
    &\multicolumn{6}{c@{}}{Confidence Interval Bounds} \\
    \cmidrule(l){2-7}
    &  \mr{2.5\%} & \mr{97.5\%} & \mr{2.5\%} & \mr{97.5\%} &\mr{2.5\%} & \multicolumn{1}{r@{}}{97.5\%} \\
    \midrule
    $\beta_0$ &-1,1034 &-0,1601 &-0,6631 &-0,1042 &-1,2247 &-0,4598 \\
    $\beta_1$  &-0,0186 &-0,0056 &-0,0112 &-0,0034 &-0,0159 &-0,0050 \\
    $\beta_2$  & 0,0443 &0,1933 &0,0219 &0,1134 & 0,0415&0,1627 \\
    $\phi$  &19,6661 &49,6969 & 19,0686 &49,1156 &20,1797&51,8046 \\
    \bottomrule
    \end{tabular}
\end{table}
\end{document}

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.