0

I'm trying to create a table similar to the one in the picture below.

I don't use LaTeX often and I am in need of some help.

Any info would be much appreciated.

enter image description here

  • package booktabs is used. – naphaneal Jun 26 '16 at 4:43
3

Here is a partial table to get your started:

\documentclass{article}
\begin{document}
\begin{table}[ht]
\caption{Effects of Moderators on the Relationship Between Exposure to Scary TV and Internalizing Responses}
\centering
\renewcommand\arraystretch{1.5}
  \begin{tabular}{l c c c c c c}
  \hline
   &  &  & \multicolumn{2}{c}{95\% CI} &  &  \\\cline{4-5}
  Moderator & \textit{k} & Estimate & Lower & Upper & \textit{Test} & \textit{p} \\\cline{1-7}
  \textbf{Study Characteristics} &  &  &  &  &  &  \\
  {Experimental or correlational} & 129 & -0.159 & -0.269 & -0.049 & $\chi^2(1)=8.08$ & .005 \\
  etc. & & & & & \\
  \hline
  \end{tabular}
\end{table}
\end{document}

yields:

enter image description here

  • Thanks! How would I do an indentation (e.g. Child vs. Parent under Responder)? – statsguyz Jun 26 '16 at 5:48
  • 1
    There may be a more proper way to do this, but I would just push the text of each cell that needs to be indented with \hspace. Swap out the etc. & ... row with: {\hspace{1em} etc.} & & & & & \\ , and of course it doesn't have to be 1em. – Jeffery Shivers Jun 26 '16 at 5:55
  • I don't think you need \bgroup/egreoup here, as it is within a table-environment. Also, the booktabs-package could make the table look more alike the example. I would also align many of the numbers, either at =-signs, or decimals, using siunitx. This of course isn't really done in the example, but there is nothing wrong with improving the look. – Runar Jun 26 '16 at 7:41
  • @Runar thanks, I've removed the group ends from the answer now – Jeffery Shivers Jun 26 '16 at 7:58
1

You can actually improve the quality by using siunitx. Here's only some relevant lines, the others will follow the same schemes.

\documentclass{article}
\usepackage{garamondx}
\usepackage{booktabs,threeparttable,siunitx,caption}

\begin{document}

\begin{table}[htp]
\centering
\captionsetup{justification=raggedright}

\begin{threeparttable}

\caption{Effects of moderators and the relationship between
  exposure to scary TV and internalizing responses}

\small
\addtolength{\tabcolsep}{-2pt}

\begin{tabular}{
  @{}
  l
  c
  *{3}{ S[table-format=-1.3] }
  c
  r
  @{}
}
\toprule
&&& \multicolumn{2}{c}{95\% CI} && \\
\cmidrule{4-5}
Moderator & $k$ & {Estimate} & {Lower} & {Upper} & \textit{Test} & \multicolumn{1}{c@{}}{$p$} \\
\midrule
\multicolumn{7}{@{}l@{}}{\textbf{Study characteristics}} \\
Experimental or correlational &
  129 & -0.159 & -0.269 & -0.049 & $\chi^2(1)=8.08$ & $.005$ \\
Responder & 129 &&&& $\chi^2(2)=0.14$ & $.056$ \\
\quad child vs.\@ parent &
      & -0.010 & -0.067 &  0.047 & $z=-0.34$ & $.736$ \\
Outcome measure & 129 &&&& $\chi^2(5)=22.39$ & $<.001$ \\
\quad general vs.\@ fear &
      &  0.213 &  0.111 &  0.315 & $z=4.11$ & $<.001$ \\
\bottomrule
\end{tabular}
\end{threeparttable}

\end{table}

\end{document}

enter image description here

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.