2

I will be grateful if you can help in creating a table like this? Especially, how to create break in the line?

enter image description here

Thank you

4

I would like to suggest a layout that's different from the one shown in your template. The two main differences are: (i) center rather than left-align the material in the header cells and (ii) align the numbers in the data columns on the respective decimal markers and use proper math-minus symbols rather than text-mode dashes. Alignment on the decimal markers may be achieved by using the D column type that's provided by the dcolumn package.

enter image description here

\documentclass{article}
\usepackage{booktabs,dcolumn,caption}
\captionsetup{skip=0.333\baselineskip}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\newcommand\mc[1]{\multicolumn{1}{@{}c@{}}{#1}} % handy shortcut macro

\begin{document}
\begin{table}
\caption*{Unit Root Test Results}
\centering
\begin{tabular}{@{} l *{2}{d{2.4}d{2.2}d{2.4}} @{}}
\toprule
Variables & \multicolumn{3}{c}{ADF Test} & \multicolumn{3}{c@{}}{KPSS Test} \\ 
\cmidrule(l){2-4} \cmidrule(l){5-7}
& \multicolumn{2}{c}{At Level} & \mc{At First} 
& \multicolumn{2}{c}{At Level} & \mc{At First} \\ 
& & & \mc{Difference} & & & \mc{Difference}\\
\cmidrule(lr){2-3} \cmidrule{4-4} \cmidrule(lr){5-6} \cmidrule{7-7}
& \mc{C} & \mc{C\&T} & \mc{C} & \mc{C} & \mc{C\&T} & \mc{C} \\ 
\midrule
GDS & -1.05 & -2.1 & -7.01^{***} & 0.73 & 0.13 & 0.07 \\
NSP & -0.74 & -2.16 & -6.98^{***} & 0.77 & 0.16 & 0.1 \\
Inflation & -4.75^{***} & \mc{NR} & \mc{NR} & 0.1 & \mc{NR} & \mc{NR} \\
GDP & 4.831 & 1.07 & -4.67^{***} & 0.79 & 0.2 & 0.73 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
2

Basically, there are three issues here:

  1. How to make sure that "ADF Test" and "KPSS Test" don't cause the corresponding columns too wide. You should make them stretch over all three columns to prevent that. This is easy by using

    \multicolumn{3}{l}{ADF Test}
    

    to stretch that over three columns ({3}), and align it left ({l}).

  2. How to make the line break in the "First Difference" cell. This is easily possible when you make these two columns have a fixed size with e.g. p{1.5cm}. Then you can use the \newline command within a cell to create a line break there.

  3. How to create the empty space between the two blocks. This can be done by adding a new column with a fixed width to the table with p{0.5cm}. You just always have to skip this column, as not to write anything in there. That is why there are is a && instead of & there in the example below.

    To make the rules be discontinued there, you can add two \cmidrule's instead of one:

    column \\ \cmidrule{2-4} \cmidrule{6-8}
    

The rest of it is "basic" tabular usage. Here's the result:

\documentclass{article}
\usepackage{booktabs}

\begin{document}
\begin{tabular}{l llp{1.5cm} p{0.5cm} llp{1.5cm}}
\toprule
& \multicolumn{3}{l}{ADF Test} && \multicolumn{3}{l}{KPSS Test} \\ \cmidrule{2-4}\cmidrule{6-8}
& At Level & & First \newline Difference && At Level & & First \newline  Difference \\ \cmidrule{2-4}\cmidrule{6-8}
Variables & C & C\&T & C && C & C\&T & C \\ \midrule
GDS & -1.05 & -2.1 & -7.01*** && 0.73 & 0.13 & 0.07 \\
NSP & -0.74 & -2.16 & -6.98*** && 0.77 & 0.16 & 0.1 \\
Inflation & -4.75*** & NR & NR && 0.1 & NR & NR \\
GDP & 4.831 & 1.07 & -4.67*** && 0.79 & 0.2 & 0.73 \\
\bottomrule
\end{tabular}

\end{document}

Resulting table

  • +1. I'd say there's a fourth issue: The numbers in the six data columns should be aligned on their decimal markers. This could be achieved by loading the dcolumn package and using the D column type (except for the textual material in the headers) for columns 2 thru 7. – Mico Jan 20 '17 at 18:58
  • @Mico true. I didn't include that because it isn't the case in the example image. Thanks for showing how that works in your answer, +1. – hbaderts Jan 20 '17 at 19:32
  • Thanks a lot @hbaderts. It really helped me. I would be grateful if you can kindly explain llp{1.5cm} p{0.5cm}. I will try with \dcolum. – santosh Jan 26 '17 at 4:08

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.