I've been failing to make a proper table where text width changes and have different sizes.
Here is the table when I use tabulary
environment.
I want to have the columns have the same size and align properly in each row. It seems the hyphen mess up with the alignment. Also the first column name, model 1
is broken into two lines.
Also in the second section, staring from the hline
and then cohort size
, the columns break into two lines instead of getting wider to fit the text.
I use the following
\begin{center}
\begin{table*}
\centering
\begin{tabulary}{\textwidth}{LCCCCCC}
\hline
\textbf{} & \textbf{Model 1} & \textbf{Model 2} & \textbf{Model 3} & \textbf{Model 4} & \textbf{Model 5} & \textbf{Model 6} \\
\textbf{} & \textit{Baseline} & \textit{Human Capital}& \textit{Gender} & \textit{Social Capital} & \textit{Symbolic Capital} & \textit{Human Capital (Ext.)}
\\
\hline
start year & 0.0(0.0) & 0.0(0.0) & 0.0(0.0) & 0.0(0.0) & 0.0(0.0) & 0.0(0.0) \\[8pt]
productivity & & $-$0.67(0.01) & $-$0.67(0.01) & $-$0.69(0.01) & $-$0.67(0.01) & $-$0.67(0.01) \\[8pt]
recognition & & 0.02(0.0) & 0.02(0.0) & 0.01(0.0) & 0.02(0.0) & 0.04(0.0) \\[8pt]
male & & & 0.05(0.01) & 0.04(0.01) & 0.06(0.01) & 0.05(0.01) \\[8pt]
female & & & $-$0.05(0.02) & $-$0.05(0.01) & $-$0.06(0.01) & $-$0.06(0.02) \\[8pt]
none & & & 0.01(0.02) & 0.01(0.01) & 0.01(0.02) & 0.01(0.02) \\[8pt]
degree & & & & 0.03(0.0) & 0.04(0.0) & 0.04(0.0) \\[8pt]
coauthor hindex & & & & $-$0.01(0.0) & $-$0.0(0.0) & $-$0.0(0.0) \\[8pt]
top-venue & & & & & $-$0.33(0.03) & $-$0.3(0.04) \\[8pt]
quality & & & & & & $-$0.0(0.0) \\[8pt] \hline
cohort size & 292,659 & 292,659 & 292,659 & 292,659 & 292,659 & 292,659 \\[8pt]
\% dropouts & 0.63 & 0.63 & 0.63 & 0.63 & 0.63 & 0.63 \\[8pt]
F1 & 0.77 & 0.81 & 0.81 & 0.81 & 0.81 & 0.81 \\[8pt]
ROC AUC & 0.48 & 0.75 & 0.75 & 0.75 & 0.76 & 0.76 \\[8pt]
Average precision & 0.62 & 0.78 & 0.79 & 0.79 & 0.8 & 0.81 \\[8pt]\hline
\end{tabulary}
\caption{\label{tab:my label} my caption}
\end{table*}
\end{center}
and this is the result when I use \begin{tabularx}{\textwidth}{XXXXXXX}
instead. It looks abit better! Plus, in the second section, staring from the hline
and then cohort size
, columns break into two lines instead of getting wider to fit the text.
I also tried to change the column sizes using %\newcolumntype{x}[1]{>{\raggedleft\hspace{0pt}}p{3}}
but it didn't work. Any idea is very appreciated!
UPDATE (temp)
After trying out @Zarko solution columns and rows alignment looks fine but the table alignment to the page is not right. The table is not in in the centre of the page and the lines no stretching till the end. I get the error overfull \hbox (68.48..) too wide in alignment in line..
UPDATE 2 This the result and code when I use the recommended code
\documentclass[pdftex,a4paper]{scrartcl}
\usepackage{abstract}
\usepackage{color}
\usepackage{comment}
\usepackage[pdftex]{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{natbib}
\usepackage{tabularx}
\usepackage{tabulary}
\usepackage{array}%
\usepackage{relsize}
\usepackage{setspace}
\usepackage{booktabs, makecell}
\usepackage{siunitx}
\newcommand\chead[1]{\multicolumn{2}{c}{\bfseries#1}}
\newcommand\mci[1]{\multicolumn{2}{c}{\itshape\makecell[t]{#1}}}
\newcommand\mcc[1]{\multicolumn{2}{c}{#1}}
%\title{Temporal Changes in Inequality and the Predictability of Success in Science: A Study of 30 Computer Science Cohorts}
\title{test}
\begin{document}
\maketitle
\begin{table*}
\centering
\setlength\tabcolsep{0pt}
\renewcommand\arraystretch{1.1}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} l*{6}{S[table-format=+1.2, table-auto-round]@{}l}}
\toprule
& \chead{Model 1} & \chead{Model 2} & \chead{Model 3}
& \chead{Model 4} & \chead{Model 5} & \chead{Model 6} \\
& \mci{Baseline} & \mci{Human\\ Capital}
& \mci{Gender}
& \mci{Social\\ Capital}
& \mci{Symbolic\\ Capital}
& \mci{Human\\ Capital\\ (Ext.)}\\
\midrule
start year
& 0.0 & (0.0) & 0.0 & (0.0) & 0.0 & (0.0) & 0.0
& (0.0) & 0.0 & (0.0) & 0.0 & (0.0) \\
productivity
& & & -0.67 & (0.01) & -0.67 & (0.01)& -0.69
& (0.01)& -0.67 & (0.01)& -0.67 & (0.01) \\
recognition
& & & 0.02 & (0.0) & 0.02 & (0.0) & 0.01
& (0.0) & 0.02 & (0.0) & 0.04 & (0.0) \\
\addlinespace
male
& & & & & 0.05 & (0.01)& 0.04
& (0.01)& 0.06 & (0.01)& 0.05 & (0.01) \\
female
& & & & & -0.05 & (0.02)& -0.05
& (0.01)& -0.06 & (0.01)& -0.06 & (0.02) \\
none
& & & & & 0.01 & (0.02)& 0.01
& (0.01)& 0.01 & (0.02)& 0.01 & (0.02) \\
\addlinespace
degree
& & & & & & & 0.03
& (0.0) & 0.04 & (0.0) & 0.04 & (0.0) \\
coauthor hindex
& & & & & & & -0.01
& (0.0) & -0.0 & (0.0) & -0.0 & (0.0) \\
top-venue
& & & & & & &
& & -0.33 & (0.03)& -0.3 & (0.04) \\
quality
& & & & & & &
& & & & -0.0 & (0.0) \\
\midrule
cohort size
& \mcc{292,659} & \mcc{292,659} & \mcc{292,659} & \mcc{292,659}
& \mcc{292,659} & \mcc{292,659} \\
\% dropouts
& 0.63 & & 0.63 & & 0.63 & & 0.63
& & 0.63 & & 0.63 & \\
F1 & 0.77 & & 0.81 & & 0.81 & & 0.81
& & 0.81 & & 0.81 & \\
ROC AUC
& 0.48 & & 0.75 & & 0.75 & & 0.75
& & 0.76 & & 0.76 & \\
Average precision
& 0.62 & & 0.78 & & 0.79 & & 0.79
& & 0.8 & & 0.81 & \\
\bottomrule
\end{tabular*}
\caption{My caption}
\label{tab:my label}
\end{table*}
\end{document}
now the horizontal lines are fine but the column spacing is not again.
table*
environment should not be insidecenter
I would not usetabulary
ortabularx
for numeric tables, they are for setting line breaking within a column. Just use a normaltabular
and a smaller font size such as\small
documentclass
you use and its page layout, I would be able to accommodate solution to it.