我不知道为什么我不能使用 \makecell 基本上,我只是想在那里有一个内容中心。这让我的生活非常困难。
\documentclass[12pt,oneside]{book}
\usepackage[showframe]{geometry}
\usepackage{amsmath}
\usepackage{ragged2e}
\usepackage{makecell, multirow, tabularx}
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\renewcommand\theadgape{}
\usepackage[svgnames, table]{xcolor}
\usepackage{hhline, boldline}
\usepackage{seqsplit, caption} %for table spacing to second row
\usepackage{booktabs, ragged2e} % Use booktabs rules and get rid of vertical rules, ragged2e to ragged text
\usepackage{siunitx} %for table spacing to second row
\usepackage{threeparttable} %to add footnote below table
\usepackage{tabulary}
\begin{document}
\begin{table}[h!]
\centering
\begin{threeparttable}
\begin{tabularx}{\textwidth}{>{\RaggedRight\arraybackslash}Xlcccc} % Changed from c to X, or remove >{} and change to `l`column.
\toprule
& & {\textbf{N}}
& {\textbf{Mean Rank}}
& {\makecell{\textbf{Sum of}\\ \textbf{Ranks}}}
% & \multicolumn{1}{>{\centering\arraybackslash}p{8em}}{\textbf{BCa 95\% Confidence Interval of the Difference}}
\\
\midrule
\multirow{2.5}{*}{\makecell{\textit{AAaaaa Example Dataset}} \\ (AA) - \\ {\textit{AAaaaa Example Dataset}} \\ (BB) }
& Negative Ranks
& 55\tnote{a}
& 2.50
& 34.00 \\
& Positive Ranks & 0\tnote{b} & 0.00 & 0.00 \\
& Ties & 0\tnote{c} & \\
& Total & 10 \\
\bottomrule
\end{tabularx}
\footnotesize
\end{threeparttable}
\end{table}
\end{document}
答案1
据我理解,您不需要makecell
在多行单元格中使用任何内容。只需重新定义它即可。对于列标题,我将使用它\thead
而不是\makecel
:
\documentclass[12pt,oneside]{book}
\usepackage[showframe]{geometry}
\usepackage[svgnames, table]{xcolor}
\usepackage{ragged2e}
\usepackage{booktabs, makecell, multirow, tabularx, threeparttable}
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\renewcommand\theadgape{}
\begin{document}
\begin{table}[ht]
\centering
\begin{threeparttable}
\begin{tabularx}{\textwidth}{>{\RaggedRight\let\\ \newline}Xl cc c}
\toprule
& & \thead[b]{N} & \thead[b]{Mean\\ Rank} & \thead[b]{Sum of\\ Ranks} \\
\midrule
\multirow{4}{=}{\itshape
AAaaaa Example Dataset\\
\normalfont
(AA) -\\
\itshape
AAaaaa Example Dataset\\
\normalfont
BB }
& Negative Ranks & 55\tnote{a} & 2.50 & 34.00 \\
& Positive Ranks & 0\tnote{b} & 0.00 & 0.00 \\
& Ties & 0\tnote{c} & & \\
& Total & 10 & & \\
\bottomrule
\end{tabularx}
\end{threeparttable}
\end{table}
\end{document}
附录:
您可能希望列宽更均匀,数字以小数点对齐。在这种情况下,使用S
列说明符(在siunitx
包中定义)和更宽的第二列可以实现您想要的效果:
\documentclass[12pt,oneside]{book}
\usepackage[showframe]{geometry}
\usepackage[svgnames, table]{xcolor}
\usepackage{ragged2e}
\usepackage{booktabs, makecell, multirow, tabularx, threeparttable}
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\renewcommand\theadgape{}
\usepackage{siunitx}
\begin{document}
\begin{table}[ht]
\centering
\sisetup{table-column-width=0.1\linewidth,
table-align-text-post=false,
table-format=2.2}
\begin{threeparttable}
\begin{tabularx}{\textwidth}{>{\RaggedRight\let\\ \newline\hsize=1.2\hsize}X
>{\hsize=0.8\hsize}X
S[table-format=2.0]SS}
\toprule
& & {\thead[b]{N}} & {\thead[b]{Mean\\ Rank}} & {\thead[b]{Sum of\\ Ranks}} \\
\midrule
\multirow{4}{=}{\itshape
AAaaaa Example Dataset\\
\normalfont
(AA) -\\
\itshape
AAaaaa Example Dataset\\
\normalfont
BB }
& Negative Ranks & 55\tnote{a} & 2.50 & 34.00 \\
& Positive Ranks & 0\tnote{b} & 0.00 & 0.00 \\
& Ties & 0\tnote{c} & & \\
& Total & 10 & & \\
\bottomrule
\end{tabularx}
\end{threeparttable}
\end{table}
\end{document}