如何让一个单词位于几行的中心?
在下面的作品中,我希望我的单词Bootstrap
位于中心。它似乎位于左侧。
我用了:
\multicolumn{5}{c}{\textbf{Bootstrap}}
我的完整 MWE:
\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}
\usepackage{graphicx}
\begin{document}
\begin{table}[h!]
\centering
% \begin{center}
%\begin{tabularx}{\textwidth}{@{}M*{6}{N}@{}}
\begin{tabularx}{\textwidth}{>{\RaggedRight\arraybackslash}cXcccccc}
\toprule
& & \multicolumn{5}{c}{\textbf{Bootstrap}} \\
\cmidrule{4-8}
&
& \multirow{4.5}{*}{\textbf{Mean}}
& \multirow{4.5}{*}{\textbf{Bias}}
& \multirow{4.5}{*}{\makecell{\textbf{Std.}\\ \textbf{Error}}}
& \multirow{4.5}{*}{\makecell{\textbf{Sig.}\\ \textbf{(2-tailed)}}}
& \multicolumn{2}{>{\centering\arraybackslash}p{8em}}{\textbf{95\% Confidence Interval of the Difference}}
\\
\cmidrule{7-8} %\cmidrule(lr){3-4}
& & & & & & \multicolumn{1}{c}{\textbf{Lower}} & \multicolumn{1}{c}{\textbf{Upper}} \\
\midrule
Pair 1
& \textit{Testing example dataset} (AA) - \textit{Testing puree Example Dataset} (BB)
& 44.76\%
& 0.19\%
& 4.35
& 0.001
& 36.67\%
& 53.33\%\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
答案1
您定义了八列,但多列行中的列数只有七列。如果添加,&
则正确。将“RaggedRight”重定向到 -column c
(如在列定义中所做的那样)是没有意义的。如果您不需要多行列(参见示例 1),则可以使用X
-column(参见示例 2)或使用 -columns :l
示例 1
这里我已将您的代码简化为 MWE。我假设您希望X
成为参差不齐的右列,因此我将一l
列作为第 1 列:
\documentclass[12pt,oneside]{book}
\usepackage[showframe]{geometry}
\usepackage{makecell, multirow, tabularx}
\usepackage{booktabs, ragged2e} % Use booktabs rules and get rid of vertical rules, ragged2e to ragged text
\begin{document}
\begin{table}[h!]
\centering
\begin{tabularx}{\textwidth}{l>{\RaggedRight\arraybackslash}Xcccccc}
\toprule
& & & \multicolumn{5}{@{}c@{}}{\textbf{Bootstrap}} \\ %% Wrong number of columns, and you can extend the mlticol and extend the cmidrile to cover six columns
\cmidrule(l){4-8}
&
& \multirow{4.5}{*}{\textbf{Mean}}
& \multirow{4.5}{*}{\textbf{Bias}}
& \multirow{4.5}{*}{\makecell{\textbf{Std.}\\ \textbf{Error}}}
& \multirow{4.5}{*}{\makecell{\textbf{Sig.}\\ \textbf{(2-tailed)}}}
& \multicolumn{2}{>{\centering\arraybackslash}p{8em}}{\textbf{95\% Confidence Interval of the Difference}}
\\
\cmidrule(l){7-8} %\cmidrule(lr){3-4}
& & & & & & \multicolumn{1}{c}{\textbf{Lower}} & \multicolumn{1}{c}{\textbf{Upper}} \\
\midrule
Pair 1
& \textit{Testing example dataset} (AA) -- \textit{Testing puree Example Dataset} (BB)
& 44.76\%
& 0.19\%
& 4.35
& 0.001
& 36.67\%
& 53.33\%\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
示例 2
\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}
\usepackage{graphicx}
\begin{document}
\begin{table}[h!]
\centering
% \begin{center}
%\begin{tabularx}{\textwidth}{@{}M*{6}{N}@{}}
\begin{tabularx}{\textwidth}{>{\RaggedRight\arraybackslash}XXcccccc} % Changed from c to X, or remove >{} and change to `l`column.
\toprule
& & & \multicolumn{5}{@{}c@{}}{\textbf{Bootstrap}} \\ %% Wrong number of columns
\cmidrule{4-8}
&
& \multirow{4.5}{*}{\textbf{Mean}}
& \multirow{4.5}{*}{\textbf{Bias}}
& \multirow{4.5}{*}{\makecell{\textbf{Std.}\\ \textbf{Error}}}
& \multirow{4.5}{*}{\makecell{\textbf{Sig.}\\ \textbf{(2-tailed)}}}
& \multicolumn{2}{>{\centering\arraybackslash}p{8em}}{\textbf{95\% Confidence Interval of the Difference}}
\\
\cmidrule{7-8} %\cmidrule(lr){3-4}
& & & & & & \multicolumn{1}{c}{\textbf{Lower}} & \multicolumn{1}{c}{\textbf{Upper}} \\
\midrule
Pair 1
& \textit{Testing example dataset} (AA) - \textit{Testing puree Example Dataset} (BB)
& 44.76\%
& 0.19\%
& 4.35
& 0.001
& 36.67\%
& 53.33\%\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}