0

The photo is from mastering metrics and is an example of what I'm looking forI'm creating a table and need help making a subsection of the column labels. Here is my code:

\begin{table}[tbp] \centering
\newcolumntype{C}{>{\centering\arraybackslash}X}
\caption{WAGE SAMPLE STATISTICS, by year and state (1983-2000)}
\begin{tabularx}{\textwidth}{lCCCCCCC}

\toprule \toprule
{state}&{1983}&{1987}&{1988}&{1993}&{1994}&{1999}&{2000} 
\tabularnewline
\midrule\addlinespace[1.5ex]
Andhra Pradesh&5.17&5.49&5.53&6.28&6.24&5.77&5.80 \tabularnewline
Gujarat&9&6.04&5.92&6.64&6.58&6.09&6.04 \tabularnewline
Haryana&12&6.25&6.43&6.80&6.60&6.54&6.74 \tabularnewline
Manipur&54&6.31&6.73&7.15&7.09&6.90&6.83 \tabularnewline
Orissa&5.24&5.90&5.96&6.16&6.26&5.57&5.58 \tabularnewline
Tamil Nadu&5.19&5.67&5.68&6.31&6.33&6.02&5.97 \tabularnewline
Uttar Pradesh&5.55&6.06&3&6.61&2&6.00&6.07 \tabularnewline
Mizoram&6.43&5.44&6.03&6.81&6.76&8&7 \tabularnewline
\bottomrule \addlinespace[1.5ex]

\end{tabularx}
\end{table}

booktabs and tabularx are the related packages. I think these are common enough but if they are not I can comment more details on them! I copy-and-pasted this from a text file I created from Stata. Basically I need to subsection label the last 7 columns with a centered subsection label and hopefully a line under that just to make it look nice. I'm not really sure how to do this. Does anybody have any tips?

The attached photo is from Mastering Metrics and is an example of what I'm looking for.

  • Welcome to TeX SX! What do you mean exactly with ‘a subsection label’? – Bernard Jun 17 '18 at 14:07
  • Do you mean something like & \multicolumn{7}{c}{some text} \\ \cmidrule{2-8}? – leandriis Jun 17 '18 at 14:17
  • @leandriis where would I put this? I can put this in and try! – Juliet Flam-Ross Jun 17 '18 at 14:22
  • @JulietFlam-Ross: If you put this line of code right after the secone \toprule command, you will get a text that is centered with respect to the last seven columns and a line under the text. – leandriis Jun 17 '18 at 14:24
  • @Bernard I just edited my post to have a picture of what I'm looking for. Sorry! I am not sure if there's a technical title for what I'm looking for but please tell me if there is. Basically I want a joint label for a bunch of column labels that describes what they are. In this case, the years are all describing logged mean wages so I don't want to have to type out over and over "logged mean wages in X year" over and over again. Does that make sense? Thank you! – Juliet Flam-Ross Jun 17 '18 at 14:25
1

How about this? tabularx isn't need, in my opinion the S columntype is better for alignment for numbers.

    \documentclass{article}
    \usepackage{tabularx, booktabs, makecell, caption}
    \usepackage{siunitx}
    \begin{document}

\begin{table}[tbp] \centering
\newcolumntype{C}{>{\centering\arraybackslash}X}
\sisetup{table-format=1.2, table-number-alignment=center}
\caption{WAGE SAMPLE STATISTICS, by year and state (1983-2000)}
%\begin{tabularx}{\textwidth}{l*{7}{S}}%{lCCCCCCC}
\begin{tabular}{lS[table-format=2.2]*{6}{S}}%{lCCCCCCC}

\toprule \toprule
\addlinespace
 & \multicolumn{7}{c}{\makecell{Logged mean wages \\ in year}} \\
 \cmidrule(lr){2-8}
{state}&{1983}&{1987}&{1988}&{1993}&{1994}&{1999}&{2000}
\tabularnewline
\cmidrule[\lightrulewidth](lr){1-8}\addlinespace[1ex]
Andhra Pradesh&5.17&5.49&5.53&6.28&6.24&5.77&5.80 \tabularnewline
Gujarat&9&6.04&5.92&6.64&6.58&6.09&6.04 \tabularnewline
Haryana&12&6.25&6.43&6.80&6.60&6.54&6.74 \tabularnewline
Manipur&54&6.31&6.73&7.15&7.09&6.90&6.83 \tabularnewline
Orissa&5.24&5.90&5.96&6.16&6.26&5.57&5.58 \tabularnewline
Tamil Nadu&5.19&5.67&5.68&6.31&6.33&6.02&5.97 \tabularnewline
Uttar Pradesh&5.55&6.06&3&6.61&2&6.00&6.07 \tabularnewline
Mizoram&6.43&5.44&6.03&6.81&6.76&8&7 \tabularnewline
\addlinespace
\bottomrule
\end{tabular}
\end{table}
\end{document} 

enter image description here

| improve this answer | |

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.