# How to write this table format as its shown in the picture

I want to use this table format in my work. I have tried to implement it, but I have been unable to obtain the same result. Please help me to access the code of this table format.

• Welcome! What have you tried? Please give us a starting point :) Having said that, you'll need a tabular, a multicolumn, and some horizontal lines. Jun 19 '17 at 6:56
• I found the solution of the problem. Dozens of thanks for immediate reply Jun 19 '17 at 7:55
• Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. Sep 17 '17 at 14:15

Here's how I'd do it. It needs a few tweaks, but hopefully this will get you pointed in the right direction. I recommend taking a look at some of the packages I've used. They probably have some useful functionality for some of the sort of tables you seem to be trying to produce.

\documentclass{article}
\usepackage{booktabs} % Adds table formatting options
\usepackage{dcolumn} % Adds option to align data around the decimal point
\newcolumntype{d}{D{.}{.}{-1}} % Use 'd' to align column on decimal place
\usepackage[labelfont={bf},singlelinecheck={off}]{caption} % Formats captions on images, tables, etc.
\newcommand{\cc}[1]{\multicolumn{1}{c}{#1}} % centralise table cell

\begin{document}

\begin{table}[tp]
\centering
\caption{caption text goes here}
\label{tbl:crossref-label}
\begin{tabular}{l d d @{\extracolsep{6pt}} d d l}
\toprule
& \multicolumn{2}{c}{multicolumn title} & \multicolumn{3}{c}{multicolumn title} \\
\cmidrule{2-3} \cmidrule{4-6}
& \cc{Mean} & \cc{SD} & \cc{Mean} & \cc{SD} & \cc{$p$} \\
\midrule
text &&&&& \\
more text & 12.34 & 1.234 & 1.23 & 1.234 & ** \\
more text & 1.23 & 1.2345 & 12.3 & 1.23 & ** \\
\bottomrule
\end{tabular}
\end{table}

\end{document}


This will display like this:

• You can use \cmidrule instead of \cline to get the same vertical distances as \midrule. Jun 19 '17 at 10:21
• Thanks. That's a better solution. I've updated my answer. Jul 3 '17 at 6:00

Here are some hints about how to customize the table as shown in the question:

• \captionsetup{justification=centering, labelfont=bf, labelsep=quad} to customize the caption as shown above.
• Equalized column widths is best handled by defining a new column type using \newcolumntype{C}{ >{ \arraybackslash \Centering } X } in the preamble where C is the new column type. Or you can use \newcolumntype{R}{ >{ \arraybackslash \RaggedLeft } X } where R is a new column type where entries are justified to the right. Many publications use such format for the first column.
• \cmidrule(lr){col} allows for trimmed rulings from left and right
• \colorbox{LightBlue}{text} to highlight in the color shown above

The overall code is:

\documentclass{report}

% Text justification package
\usepackage{ragged2e}

% Table packages
\usepackage{booktabs}
\usepackage{tabularx}

% New column types
\newcolumntype{C}{ >{ \arraybackslash \Centering } X } % centered
\newcolumntype{L}{ >{ \arraybackslash \RaggedRight } X } % left justified
\newcolumntype{R}{ >{ \arraybackslash \RaggedLeft } X } % right justified
\newcolumntype{S}[1]{ >{ \arraybackslash \Centering } m{#1} } % centered with specified width

% Caption package
\usepackage{caption}
\captionsetup{justification=centering, labelfont=bf, labelsep=quad} % centers floats caption, makes float name in bold font, and adds space between float name and the caption

% Highlighting packages
\usepackage[svgnames]{xcolor}

% Shortcut command for highlighting in LightBlue
\newcommand{\LB}[1]{\colorbox{LightBlue}{#1}}

\begin{document}

\begin{table}[htp]

% Center the table
\centering

\caption{Scholarly works, time allocation, satisfaction, and income by US-versus foreign-born status}
\label{tbl:crossref-label}

\begin{tabularx}{1\textwidth}{C >{\hsize=0.2\hsize}C >{\hsize=0.2\hsize}C >{\hsize=0.2\hsize}C >{\hsize=0.2\hsize}C >{\hsize=0.2\hsize}C }

\toprule[0.8pt]

&
\multicolumn{2}{S{0.9in}}{Born in US N = $2900^{*}$} &
\multicolumn{3}{S{1.4in}}{Foreign Born N = $1190$}
\\
\cmidrule(lr){2-3} \cmidrule(lr){4-6}

& Mean & SD & Mean & SD & $p$
\\
\midrule

Recent Scholarly Works & & & & &
\\

\LB{Refereed Articles} & \LB{12.34} & \LB{1.234} & \LB{1.23} & \LB{1.234} & \LB{**}
\\

\bottomrule[0.8pt]

\end{tabularx}

\end{table}

\end{document}


Using @Ulysses answer as missing MWE in question .., , packages siunitx and threeparttable for S column type and for limit table caption to table width and eventually add table notes below table for example for description of ** in last column (it is not clear what they meaning) respectively:

\documentclass{article}
\usepackage{booktabs, threeparttable}
\usepackage{siunitx} % Formats units, numbers, numbers in table
\usepackage[font=small, labelfont=bf, skip=1ex]{caption} % Formats captions of floats
\newcommand{\mcx}[2]{\multicolumn{#1}{c}{#2}} % shortcut for multicolumn

\begin{document}
\begin{table}[ht]
\centering
\begin{threeparttable}
\caption{Scholarly works, time allocation, satisfaction, and income by US-versus foreign-born status}
\label{tbl:crossref-label}
\begin{tabular}{l *{2}{S[table-format=2.2] S[table-format=1.4]} c}
\toprule
& \mcx{2}{multicolumn title}    & \mcx{3}{multicolumn title}    \\
\cmidrule(lr) {2-3} \cmidrule(lr){4-6}
& {Mean}    & {SD}              & {Mean}    & {SD}  & $p$       \\
\midrule
text        &           &                   &           &       &           \\
more text   & 12.34     & 1.234             & 1.23      & 1.234 & **        \\
more text   & 1.23      & 1.2345            & 12.3      & 1.23  & **        \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}