这是来自上一个问题的问题链接如何将表格的表头从 2 行改为 4 行?
建议的答案是使用:
\multirow{-4}{*}{\thead{Pair number \\
我不明白 的意思-4
。通常是positive number
。
基本上,我希望内容位于中心,这样表格看起来会更美观
妇女权利委员会:
\documentclass[12pt,oneside]{book}
\usepackage[showframe]{geometry}
\usepackage{amsmath}
\usepackage{ragged2e}
\usepackage{booktabs, makecell, multirow, tabularx,
threeparttable, tabulary}
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\renewcommand\theadgape{}
\usepackage[svgnames, table]{xcolor}
\usepackage{siunitx} %for table spacing to second row
\usepackage{graphicx}
\usepackage[font=small,
labelfont={bf,sf}, textfont={sf},
justification=centering]{caption}
\begin{document}
\begin{table}[ht]
\centering
\begin{tabular}{lrr}
\toprule
& & \\ % fake line
\addlinespace
& \multicolumn{2}{c}{\thead{Accuracy Accu Accuracy (\%)}}\\
\cmidrule{2-3}
\multirow{-4}{*}{\thead{Pair number \\
(Class 11 sample sample \& \\
Class 22 sample sample \\
Reference X sample sample)}}
& \textbf{Accuracy} & \textbf{Inaccuracy} \\
\midrule
Pair 11 (A8 \& B35) & 0 & 0 \\
Pair 12 (A10 \& B42) & 0 & 0 \\
Pair 13 (A8 \& B32) & 0 & 0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
以下是我尝试过的解决方案。
(1)如果我删除我们的& & \\ %fake line
,并添加几个\addlinespace
\begin{table}[ht]
\centering
\begin{tabular}{lrr}
\toprule
& & \\ % fake line
\addlinespace
\addlinespace
\addlinespace
\addlinespace
& \multicolumn{2}{c}{\thead{Accuracy Accu Accuracy (\%)}}\\
\cmidrule{2-3}
\multirow{-4}{*}{\thead{Pair number \\
(Class 11 sample sample \& \\
Class 22 sample sample \\
Reference X sample sample)}}
& \textbf{Accuracy} & \textbf{Inaccuracy} \\
& & \\ % fake line
\midrule
(2)我尝试将其添加& & \\ %fake line
到底部。但看上去很丑。
\begin{tabular}{lrr}
\toprule
% & & \\ % fake line
\addlinespace
\addlinespace
\addlinespace
\addlinespace
& \multicolumn{2}{c}{\thead{Accuracy Accu Accuracy (\%)}}\\
\cmidrule{2-3}
\multirow{-4}{*}{\thead{Pair number \\
(Class 11 sample sample \& \\
Class 22 sample sample \\
Reference X sample sample)}}
& \textbf{Accuracy} & \textbf{Inaccuracy} \\
% & & \\ % fake line
\midrule
(3)我正在服用
\multirow
和\multicolumn
一起使用。
& \mutlirow{0}{*}{\multicolumn{2}{c}{\thead{Accuracy Accu Accuracy (\%)}}}\\
但没法弥补。
答案1
\addlinespace
使用和 的解决方案\arraystretch
:
\documentclass[12pt,oneside]{book}
\usepackage[showframe]{geometry}
\usepackage{amsmath}
\usepackage{ragged2e}
\usepackage{booktabs, makecell, multirow, tabularx,
threeparttable, tabulary}
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\renewcommand\theadgape{}
\usepackage[svgnames, table]{xcolor}
\usepackage{siunitx} %for table spacing to second row
\usepackage{graphicx}
\usepackage[font=small,
labelfont={bf,sf}, textfont={sf},
justification=centering]{caption}
\begin{document}
\begin{table}[ht]
\centering\renewcommand{\theadset}{\renewcommand{\arraystretch}{0.75}}
\begin{tabular}{lrr}
\toprule
\addlinespace[0.8ex]
\multirowthead{2}{Pair number \\
(Class 11 sample sample \& \\
Class 22 sample sample \\
Reference X sample sample)} & \multicolumn{2}{c}{\thead{Accuracy Accu Accuracy (\%)}}\\
\addlinespace[0.6ex]
\cmidrule{2-3}
\addlinespace[0.3ex]
& \thead[r]{Accuracy} & \thead[r]{Inaccuracy} \\
\addlinespace[1ex]
\midrule
Pair 11 (A8 \& B35) & 0 & 0 \\
Pair 12 (A10 \& B42) & 0 & 0 \\
Pair 13 (A8 \& B32) & 0 & 0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
考虑到您评论中提供的补充信息上一个问题,这里有三种可能的布局。就我个人而言,我更喜欢最后一种。
\documentclass[12pt,oneside]{book}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{ragged2e}
\usepackage{booktabs, makecell, multirow, tabularx,
threeparttable, tabulary}
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\renewcommand\theadgape{}
\usepackage[svgnames, table]{xcolor}
\usepackage{siunitx} %for table spacing to second row
\usepackage{graphicx}
\usepackage[font=small,
labelfont={bf,sf}, textfont={sf},
justification=centering]{caption}
\begin{document}
\begin{table}[ht]
\centering
\begin{tabular}{lrr}
\toprule
\multirow{4.5}{*}{\thead{Pair number \\
(Class 11 tolerance sample \& \\
Class 22 tolerance sample \\
Reference X tolerance sample)}} & \\ % fake line
& \multicolumn{2}{c}{\thead{Measurement of Accuracy (\%)}}\\
\cmidrule{2-3}
& \textbf{Accuracy} & \textbf{Inaccuracy} \\
\\
\midrule
Pair 11 (A8 \& B35 \& X22) & 0 & 0 \\
Pair 12 (A10 \& B42) & 0 & 0 \\
Pair 13 (A8 \& B32) & 0 & 0 \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}[ht]
\centering
\begin{tabular}{lrr}
\toprule
\addlinespace
& \multicolumn{2}{c}{\thead{Measurement of\\ Accuracy (\%)}}\\
\cmidrule{2-3}
\multirow{-3}{*}{\thead{Pair number
(Class 11 tolerance \\sample \&
Class 22 tolerance sample \\
Reference X tolerance sample)}}
& \textbf{Accuracy} & \textbf{Inaccuracy} \\
\midrule
Pair 11 (A8 \& B35 \& X22) & 0 & 0 \\
Pair 12 (A10 \& B42) & 0 & 0 \\
Pair 13 (A8 \& B32) & 0 & 0 \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}[ht]
\centering
\begin{tabular}{lrr}
\toprule
\thead{Pair number} & \thead{Accuracy (\%)} & \thead{Inaccuracy (\%)} \\
\midrule
Pair 11 (A8 \& B35 \& X22) & 0 & 0 \\
Pair 12 (A10 \& B42) & 0 & 0 \\
Pair 13 (A8 \& B32) & 0 & 0 \\
\midrule
\multicolumn{3}{p{10cm}}{\footnotesize A.. = Class 11 tolerance sample, B.. = Class 22 tolerance sample, X.. = Reference X tolerance sample}\\
\bottomrule
\end{tabular}
\end{table}
\end{document}