3

How can I create a table like this: enter image description here

I'm struggling with the header.

closed as unclear what you're asking by Werner, CarLaTeX, Mensch, lockstep, TeXnician Jul 21 '17 at 18:57

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    the booktabs package for better lines, \multicolumn for the headers. – daleif Jul 19 '17 at 10:22
  • 1
    This is a very poorly formulated question. Not searchable at all and shows no research effort. – Werner Jul 21 '17 at 16:36
6

This will only look good as long as the data has the same size

\documentclass{memoir}

% not really needed since this is memoir
\usepackage{booktabs,array}

\begin{document}

\begin{table}
  \centering
  \begin{tabular}{lllllllllll}
    \toprule
    $p=p_0$ 
    & \multicolumn{2}{l}{$n=10$}  
    & \multicolumn{2}{l}{$14$}  
    & \multicolumn{2}{l}{$20$}  
    & \multicolumn{2}{l}{$27$}  
    & \multicolumn{2}{l}{$50$}  
    \\
    \cmidrule(lr){2-3}
    \cmidrule(lr){4-5}
    \cmidrule(lr){6-7}
    \cmidrule(lr){6-7}
    \cmidrule(lr){8-9}
    \cmidrule(lr){10-11}
    & 1 & 2
    & 1 & 2
    & 1 & 2
    & 1 & 2
    & 1 & 2
    \\    
    \midrule
    1.234 & 1.234 & 1.234 & 1.234 & 1.234 & 1.234 & 1.234 & 1.234 &
    1.234 & 1.234 & 1.234 
    \\
    \bottomrule
  \end{tabular}
\end{table}


\end{document}

enter image description here

4

I've added some improvements for the caption and the font. Slightly changed the table header layout:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\usepackage{booktabs,array, threeparttable, caption}
\usepackage{newtxtext, newtxmath}

\begin{document}

\begin{table}
  \centering
  \captionsetup{singlelinecheck=off, labelsep=newline}
  \begin{threeparttable}
    \caption{Exact sizes of the usual test (1) and the new test (2) when $α= 0.05$}
    \begin{tabular}{*{11}{l}}
      \toprule
      \multicolumn{1}{r}{$n = $} & \multicolumn{2}{l}{$10$}
                                 & \multicolumn{2}{l}{$14$}
                                 & \multicolumn{2}{l}{$20$}
                                 & \multicolumn{2}{l}{$27$}
                                 & \multicolumn{2}{l}{$50$}
      \\
      \cmidrule(lr){2-3}
      \cmidrule(lr){4-5}
      \cmidrule(lr){6-7}
      \cmidrule(lr){8-9}
      \cmidrule(lr){10-11}
      $p=p₀$ & 1 & 2 & 1 & 2 & 1 & 2 & 1 & 2 & 1 & 2
      \\
      \midrule
      0.05 & 0.012 & 0.012 & 0.004 & 0.030 & 0.016 & 0.016 & 0.010 & 0.044 & 0.012 & 0.038 \\
      0.10 & 0.013 & 0.013 & 0.009 & 0.044 & 0.011 & 0.043 & 0.015 & 0.047 & 0.030 & 0.030 \\
      0.15 & 0.010 & 0.050 & 0.012 & 0.047 & 0.022 & 0.022 & 0.026 & 0.026 & 0.027 & 0.044 \\
      0.20 & 0.006 & 0.033 & 0.012 & 0.044 & 0.022 & 0.044 & 0.030 & 0.049 & 0.033 & 0.049 \\
      0.25 & 0.020 & 0.020 & 0.028 & 0.010 & 0.038 & 0.017 & 0.042 & 0.042 & 0.033 & 0.048 \\
      \bottomrule
    \end{tabular}
  \end{threeparttable}
\end{table}

\end{document} 

enter image description here

3

Might help you, at least the template I believe :)

\documentclass[10pt,a4paper]{article}
\begin{document}
\begin{table}
\centering
\caption{Fill up the table for yourself :)}
\label{my-label}
\begin{tabular}{lllllllllllllll}
    \hline
    \multicolumn{1}{c}{a} & \multicolumn{3}{l}{b} & \multicolumn{3}{l}{c} & \multicolumn{3}{l}{d} & \multicolumn{3}{l}{f} & \multicolumn{2}{l}{g} \\ \cline{2-3} \cline{5-6} \cline{8-9} \cline{11-12} \cline{14-15} 
    & 1      & 2     &      & 1      & 2     &      & 1      & 2     &      & 1      & 2      &     & 1         & 2         \\ \hline
    1                     & 2      & 3     &      & 5      & 6     &      & 8      & 9     &      & 10     & 11     &     & 12        & 13        \\
    2                     & 2      & 3     &      & 5      & 6     &      & 8      & 9     &      & 10     & 11     &     & 12        & 13        \\
    3                     & -      & -     &      & -      & -     &      & -      & -     &      & -      & -      &     & -         & -         \\
    4                     & -      & -     &      & -      & -     &      & -      & -     &      & -      & -      &     & -         & -         \\
    5                     & -      & -     &      & -      & -     &      & -      & -     &      & -      & -      &     & -         & -         \\
    6                     & -      & -     &      & -      & -     &      & -      & -     &      & -      & -      &     & -         & -         \\
    7                     & -      & -     &      & -      & -     &      & -      & -     &      & -      & -      &     & -         & -         \\
    8                     & -      & -     &      & -      & -     &      & -      & -     &      & -      & -      &     & -         & -         \\
    9                     & -      & -     &      & -      & -     &      & -      & -     &      & -      & -      &     & -         & -         \\
    10                    & -      & -     &      & -      & -     &      & -      & -     &      & -      & -      &     & -         & -         \\ \hline
\end{tabular}
\end{table}
\end{document}

to get as you wanted as in

enter image description here

Final note, make sure to fill up the table for yourself.

  • 1
    You might want to use the rules from booktabs, then the lines does not come so close to the data – daleif Jul 19 '17 at 10:46
  • @daleif Cool one, I never knew about that today. Thanks +1 for that :D – Raaja Jul 19 '17 at 11:13
1

If the table somehow fits in the text width, you can let TeX compute automatically the intercolumn space (but check whether it turns out to be too small).

I provide two solutions, one for entries that have the same number of digits, one for other cases, with siunitx.

\documentclass{article}
\usepackage{booktabs,siunitx}
\usepackage{newtxtext, newtxmath}

\begin{document}

\begin{table}[htp]
\centering
\caption{Exact sizes of the usual test~(1) and the new test~(2) when $\alpha=0.05$}

\setlength{\tabcolsep}{0pt}

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  l *{10}{c}
  @{}
}
\toprule
{$p=p_0$} &
\multicolumn{2}{l}{$n=10$} &
\multicolumn{2}{l}{$14$}   &
\multicolumn{2}{l}{$20$}   &
\multicolumn{2}{l}{$27$}   &
\multicolumn{2}{l@{}}{$50$}
\\
\cmidrule{2-3}\cmidrule{4-5}\cmidrule{6-7}\cmidrule{8-9}\cmidrule{10-11}
&
\multicolumn{1}{l}{1} & \multicolumn{1}{l}{2} &
\multicolumn{1}{l}{1} & \multicolumn{1}{l}{2} &
\multicolumn{1}{l}{1} & \multicolumn{1}{l}{2} &
\multicolumn{1}{l}{1} & \multicolumn{1}{l}{2} &
\multicolumn{1}{l}{1} & \multicolumn{1}{l@{}}{2}
\\
\midrule
0.05 & 0.012 & 0.012 & 0.004 & 0.030 & 0.016 & 0.016 & 0.010 & 0.044 & 0.012 & 0.038 \\
0.10 & 0.013 & 0.013 & 0.009 & 0.044 & 0.011 & 0.043 & 0.015 & 0.047 & 0.030 & 0.030 \\
0.15 & 0.010 & 0.050 & 0.012 & 0.047 & 0.022 & 0.022 & 0.026 & 0.026 & 0.027 & 0.044 \\
0.20 & 0.006 & 0.033 & 0.012 & 0.044 & 0.022 & 0.044 & 0.030 & 0.049 & 0.033 & 0.049 \\
0.25 & 0.020 & 0.020 & 0.028 & 0.010 & 0.038 & 0.017 & 0.042 & 0.042 & 0.033 & 0.048 \\
\bottomrule
\end{tabular*}

\end{table}

\begin{table}[htp]
\centering
\caption{Exact sizes of the usual test~(1) and the new test~(2) when $\alpha=0.05$}

\setlength{\tabcolsep}{0pt}

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  S[table-format=1.2]
  *{10}{S[table-format=1.3]}
  @{}
}
\toprule
{$p=p_0$} &
\multicolumn{2}{l}{$n=10$} &
\multicolumn{2}{l}{$14$}   &
\multicolumn{2}{l}{$20$}   &
\multicolumn{2}{l}{$27$}   &
\multicolumn{2}{l@{}}{$50$}
\\
\cmidrule{2-3}\cmidrule{4-5}\cmidrule{6-7}\cmidrule{8-9}\cmidrule{10-11}
&
\multicolumn{1}{l}{1} & \multicolumn{1}{l}{2} &
\multicolumn{1}{l}{1} & \multicolumn{1}{l}{2} &
\multicolumn{1}{l}{1} & \multicolumn{1}{l}{2} &
\multicolumn{1}{l}{1} & \multicolumn{1}{l}{2} &
\multicolumn{1}{l}{1} & \multicolumn{1}{l@{}}{2}
\\
\midrule
0.05 & 0.012 & 0.012 & 0.004 & 0.030 & 0.016 & 0.016 & 0.010 & 0.044 & 0.012 & 0.038 \\
0.10 & 0.013 & 0.013 & 0.009 & 0.044 & 0.011 & 0.043 & 0.015 & 0.047 & 0.030 & 0.030 \\
0.15 & 0.010 & 0.050 & 0.012 & 0.047 & 0.022 & 0.022 & 0.026 & 0.026 & 0.027 & 0.044 \\
0.20 & 0.006 & 0.033 & 0.012 & 0.044 & 0.022 & 0.044 & 0.030 & 0.049 & 0.033 & 0.049 \\
0.25 & 0.020 & 0.020 & 0.028 & 0.010 & 0.038 & 0.017 & 0.042 & 0.042 & 0.033 & 0.048 \\
\bottomrule
\end{tabular*}

\end{table}

\end{document} 

I left out the formatting of the caption, that probably depends on the class you're using. With the caption package it's easy to format it as you please.

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.