3

I'm trying to get the 'N' in the first column to appear in the middle, not at the top. The code is below:

\documentclass{article}
\usepackage{array}
\usepackage{caption}
\captionsetup{labelformat=empty}
\usepackage[euler]{textgreek}
\usepackage{booktabs,tabularx}
\usepackage[margin=1in]{geometry} % set margins to meet your document's needs
\newcolumntype{Y}{>{\centering\arraybackslash}X} 
   % use ragged-right, not fully-justified, look in narrow columns
\begin{document}
\begin{table}[t]
\caption{Table 2: Length and distance between ditropic contexts in the reading material (measured in words)} 
%\centering  % not needed, since table is as wide as text block
\begin{tabularx}{\textwidth}{@{}lYYYYYY@{}}
\toprule
& {\bfseries N} 
&\multicolumn{3}{c}{\bfseries Length} 
&\multicolumn{2}{c}{\bfseries Distance} \\
 \cmidrule(l){3-5} \cmidrule(l){6-7}
&& tokens
& \textmugreek
& \textsigma
& \textmugreek
& \textsigma\\
\midrule
entire text & --- & 1855 & 14.4 & 6.5 & --- & --- \\
all contexts & 17 & 225 & 13.2 & 5.2 & 91.2 & 68.7 \\
idioms & 9 & 33 & 3.7 & 0.8 & --- & ---\\
idiomatic contexts & 8 & 110 & 13.8 & 5.6 & 170.4 & 110\\
literal contexts & 9 & 115 & 12.8 & 4.7 & 194.4 & 173.4 \\
ditropic pairs & 9 & 225 & --- & --- & 882 & 374.6 \\
\bottomrule
\end{tabularx}
\caption{the entire text contained 129 sentences}
\end{table}
\end{document}

Thanks.

Came up with a similar solution in the meantime (thanks a lot for your help, will include the improvements):

\usepackage{multirow}
\begin{tabularx}{\textwidth}{@{}lYYYYYY@{}}
\toprule
&\multirow{2}{*}[-2pt]{\bfseries N}
&\multicolumn{3}{c}{\bfseries Length} 
&\multicolumn{2}{c}{\bfseries Distance} \\
\cmidrule(l){3-5} \cmidrule(l){6-7}
1

Just use multirow and add a small correction with the optional argument.

I also propose another layout, to align the data on the decimal dot, with the siunitx package, and threeparttable:

\documentclass{article}
\usepackage{array}
\usepackage{caption}
\captionsetup{labelformat=empty}
\usepackage[euler]{textgreek}
\usepackage{booktabs,tabularx, multirow, siunitx}
\usepackage[flushleft]{ threeparttable} %
\usepackage[margin=1in]{geometry} % set margins to meet your document's needs
\newcolumntype{Y}{>{\centering\arraybackslash}X}
   % use ragged-right, not fully-justified, look in narrow columns

\begin{document}
\begin{table}[t]
\caption{Table 2: Length and distance between ditropic contexts in the reading material (measured in words)}
%\centering % not needed, since table is as wide as text block
\begin{tabularx}{\textwidth}{@{}l*{6}{Y}@{}}
\toprule
& \multirow{2}{=}[-\dimexpr\aboverulesep+\belowrulesep]{\centering\bfseries N}
&\multicolumn{3}{c}{\bfseries Length}
&\multicolumn{2}{c}{\bfseries Distance} \\
 \cmidrule(l){3-5} \cmidrule(l){6-7}
&& tokens
& \textmugreek
& \textsigma
& \textmugreek
& \textsigma\\
\midrule
entire text & --- & 1855 & 14.4 & 6.5 & --- & --- \\
all contexts & 17 & 225 & 13.2 & 5.2 & 91.2 & 68.7 \\
idioms & 9 & 33 & 3.7 & 0.8 & --- & ---\\
idiomatic contexts & 8 & 110 & 13.8 & 5.6 & 170.4 & 110\\
literal contexts & 9 & 115 & 12.8 & 4.7 & 194.4 & 173.4 \\
ditropic pairs & 9 & 225 & --- & --- & 882 & 374.6 \\
\bottomrule
\addlinespace
\end{tabularx}
\caption{the entire text contained 129 sentences}
\end{table}

\begin{table}[!ht]
\centering
\begin{threeparttable}
\caption{Table 2: Length and distance between ditropic contexts in the reading material (measured in words)}
%\centering % not needed, since table is as wide as text block
\begin{tabular}{@{\,}lcS[table-format=4.0]S[table-format=2.1]c *{2}{S[table-format=3.1]}@{\,}}
\toprule
& \multirow{2}{*}[-\dimexpr\aboverulesep+\belowrulesep]{\bfseries N}
&\multicolumn{3}{c}{\bfseries Length}
&\multicolumn{2}{c}{\bfseries Distance} \\
 \cmidrule(l){3-5} \cmidrule(l){6-7}
&& {tokens}
& {\textmugreek}
& \textsigma
& {\textmugreek}
& {\textsigma}\\
\midrule
entire text & --- & 1855 & 14.4 & 6.5 & {---} &{ ---} \\
all contexts & 17 & 225 & 13.2 & 5.2 & 91.2 & 68.7 \\
idioms & 9 & 33 & 3.7 & 0.8 & {---} & {---}\\
idiomatic contexts & 8 & 110 & 13.8 & 5.6 & 170.4 & 110\\
literal contexts & 9 & 115 & 12.8 & 4.7 & 194.4 & 173.4 \\
ditropic pairs & 9 & 225 &{ ---} & {---} & 882 & 374.6 \\
\bottomrule
\end{tabular}
\smallskip
\begin{tablenotes}
\item{the entire text contained 129 sentences}
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document} 

enter image description here

0

You can use the multirow package:

\documentclass{article}
\usepackage{array}
\usepackage{caption}
\captionsetup{labelformat=empty}
\usepackage[euler]{textgreek}
\usepackage{booktabs,tabularx}
\usepackage{multirow}
\usepackage[margin=1in]{geometry} % set margins to meet your document's needs
\newcolumntype{Y}{>{\centering\arraybackslash}X} 
   % use ragged-right, not fully-justified, look in narrow columns
\begin{document}
\begin{table}[t]
\caption{Table 2: Length and distance between ditropic contexts in the reading material (measured in words)} 
%\centering  % not needed, since table is as wide as text block
\begin{tabularx}{\textwidth}{@{}lYYYYYY@{}}
\toprule
& \multirow{2.5}{*}{\bfseries N} 
&\multicolumn{3}{c}{\bfseries Length} 
&\multicolumn{2}{c}{\bfseries Distance} \\
 \cmidrule(l){3-5} \cmidrule(l){6-7}
&& tokens
& \textmugreek
& \textsigma
& \textmugreek
& \textsigma\\
\midrule
entire text & --- & 1855 & 14.4 & 6.5 & --- & --- \\
all contexts & 17 & 225 & 13.2 & 5.2 & 91.2 & 68.7 \\
idioms & 9 & 33 & 3.7 & 0.8 & --- & ---\\
idiomatic contexts & 8 & 110 & 13.8 & 5.6 & 170.4 & 110\\
literal contexts & 9 & 115 & 12.8 & 4.7 & 194.4 & 173.4 \\
ditropic pairs & 9 & 225 & --- & --- & 882 & 374.6 \\
\bottomrule
\end{tabularx}
\caption{the entire text contained 129 sentences}
\end{table}
\end{document}

N centred in 2 and a half rows

I've used 2.5 rows for the nrows argument of \multirow, because booktabs' \midrule adds some extra space. So the multi-row should be higher than two rows without rule.

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.