2

Hi i'm trying to create this table but i couldn't fix the headers, here my suggestion and what i wanted as output

my suggestions :

       \documentclass{article}
       \usepackage{geometry}
       \usepackage{rotating}
       \usepackage{booktabs, makecell}
       \usepackage[referable]{threeparttablex}
        \usepackage{siunitx}
      \usepackage[skip=1ex]{caption}
       \NewExpandableDocumentCommand\mcc{O{1}m}
       {\multicolumn{#1}{>{\bfseries}c}{#2}}
      \begin{document}

  \begin{table}[h!]
   \centering
  \begin{threeparttable}
   \caption{Individual ARDL model forecasting results}
    \label{tab1}
      \begin{tabular}{@{} >{\itshape}l
                   *{8}{S[table-format=3.2]}
                    }
\toprule
  \multirow{2.1}{*}{Predictor} 
& \mcc[4]{1995:04-2005:03 out-of-sample period} & \mcc[4]{1985:04–2005:03 out-of-sample period}   \\
 \cmidrule(l){2-5} \cmidrule(l){6-9}
& \mcc{h=1} & \mcc{h=3} & \mcc{h=6} & \mcc{h=12}
& \mcc{h=1} & \mcc{h=3} & \mcc{h=6} & \mcc{h=12}                 \\
\midrule
AR benchmark& 9.13& 2.99& 1.79& 1.14& 8.75& 2.77& 1.68& 1.19\\
Weekly manufacturing hours& 1.00& 1.00& 1.00& 1.10& 1.00& 1.00& 1.00& 1.09\\
\bottomrule
 \end{tabular}
  \end{threeparttable}
 \end{table}
  \end{document}

my output :

enter image description here what i want : enter image description here

4
  • What is the \mcc command, if you don't mind?
    – Bernard
    Commented Mar 22, 2021 at 18:26
  • \NewExpandableDocumentCommand\mcc{O{1}m} {\multicolumn{#1}{>{\bfseries}c}{#2}}
    – haithem
    Commented Mar 22, 2021 at 18:32
  • If I make your MWE compilable by adding multirow, I get the following output i.sstatic.net/0fvp8.png which is quite different from yours.
    – leandriis
    Commented Mar 22, 2021 at 18:40
  • @leandriis yes because i forgot to add the command mc as outlined above but i still don"t have a nice looking table ! any suggestions please
    – haithem
    Commented Mar 22, 2021 at 18:42

1 Answer 1

3

enter image description here

In order to add manual linebreaks in the lengthy column headers, I used the \thead command from the makecell package that you already loaded. Additionally, I also corrected the wrong table-format option for all columns and did some minor changes to one of the \cmidrule commands in order to increase the gap between adjacent cmidrules. I did, however, not address the italic/bold text in the first column and the column headers, another difference between the current output and the image of the expected output.

\documentclass{article}
\usepackage{geometry}
\usepackage{rotating}
\usepackage{booktabs, makecell}
\usepackage[referable]{threeparttablex}
\usepackage{siunitx}
\usepackage[skip=1ex]{caption}
 \NewExpandableDocumentCommand\mcc{O{1}m}
 {\multicolumn{#1}{>{\bfseries}c}{#2}}
\usepackage{multirow}
\renewcommand{\theadfont}{\normalsize} %<------ added

\begin{document}
\begin{table}[h!]
  \centering
  \begin{threeparttable}
    \caption{Individual ARDL model forecasting results}
    \label{tab1}
    \begin{tabular}{@{} >{\itshape}l
                   *{8}{S[table-format=1.2]}% <----- corrected wrong table-format option
                    }
      \toprule
      \multirow{2.1}{*}{Predictor} 
      & \mcc[4]{\thead{1995:04-2005:03\\ out-of-sample period}} 
      & \mcc[4]{\thead{1985:04–2005:03\\ out-of-sample period}}   \\ % <------ added thead command and manual line break 
      \cmidrule(r){2-5} \cmidrule(l){6-9} % first cmidrule: replaced (l) with (r) to increase gap
      & \mcc{h=1} & \mcc{h=3} & \mcc{h=6} & \mcc{h=12}
      & \mcc{h=1} & \mcc{h=3} & \mcc{h=6} & \mcc{h=12}                 \\
      \midrule
      AR benchmark& 9.13& 2.99& 1.79& 1.14& 8.75& 2.77& 1.68& 1.19\\
      Weekly manufacturing hours& 1.00& 1.00& 1.00& 1.10& 1.00& 1.00& 1.00& 1.09\\
      \bottomrule
    \end{tabular}
  \end{threeparttable}
\end{table}
\end{document}

You must log in to answer this question.

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