0

I would like to mimecry the following table in LateX:

enter image description here

I have tried the following code but I am having hard time to get the partial line on the top (the content is not important, only the top line to specify to 'Tukey comparisons'):

\begin{table}[!htbp] \centering 
  \caption{} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}} ccccccc} 
\hline\\[-1.8ex] 
\multicolumn{6}{c}{Tukey’s HSD comparisons}\\
\hline\\[-1.8ex] 
group & n & Mean & SD & 1998 & 1999 & 2000 \\ 
\hline\\[-1.8ex] 
1998 & 256 & 79.71 & 13.40 &  & & \\ 
1999 & 307 & 82.34 & 13.30 & .005 & & \\ 
2001 & 292 & 92.23 & 6.57 & $<$.001 & $<$.001 & $<$.032 \\
\hline \\[-1.8ex] 
\end{tabular} 
\end{table}  

I would be grateful for some tips here.enter image description here

  • 1
    \cmidrule from the booktabs package – leandriis May 1 at 14:39
2

To move the heading to the last three columns: &&&&\multicolumn{3}{c}{Tukey’s HSD comparisons} and either \cline or \cmidrule for the partial rule (the first has better spacing)

\documentclass{article}

\usepackage{booktabs}
\usepackage{caption}

\begin{document}


\begin{table}[!htbp] \centering 
  \caption{} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}} ccccccc} 
\toprule
&&&&\multicolumn{3}{c}{Tukey’s HSD comparisons}\\
\cmidrule{5-7}
group & n & Mean & SD & 1998 & 1999 & 2000 \\ 
\midrule
1998 & 256 & 79.71 & 13.40 &  & & \\ 
1999 & 307 & 82.34 & 13.30 & .005 & & \\ 
2001 & 292 & 92.23 & 6.57 & $<$.001 & $<$.001 & $<$.032 \\
\bottomrule
\end{tabular} 
\end{table}  

\end{document}

enter image description here

  • 2
    Welcome to TeX.SE! I would add also \usepackage{caption} for a better caption positioning, and siunitx for the numbers alignment. – CarLaTeX May 1 at 14:45
  • @CarLaTeX Approved your precious comment. – Sebastiano May 1 at 14:49
  • 2
    @CarLaTeX Great hint! Thanks! – user187977 May 1 at 14:51

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.