
\multirow \multicolumnの両方を使用してテーブルを作成するのに問題があります
両方の内容が重なり合っていて見栄えがよくないようです。
私の完全な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}
\usepackage[font=small,labelfont={bf,sf}, textfont={sf}, justification=centering]{caption}
\begin{document}
\begin{table}[h!]
\centering
\sisetup{table-format=3.0, table-number-alignment=center, table-column-width=2.0cm}
\begin{tabular}{lSS}
\toprule
\multirow{2}{*}{\textbf{Test Cases (Class A \& Class B)}} & \multicolumn{2}{c}{\thead{\makebox[0pt]{Arrangement Accuracy (\%)}}}\\
\cmidrule{2-3}
&{\textbf{AM}}
& {\textbf{FM}} \\
\midrule
Pairs of Samples 1 (A5 \& B42) & 333.33 & 1300.00 \\
Pairs of Samples 2 (A20 \& B44) & 47.44 & 77.35 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答え1
ヘッダー要素が衝突しそうになった表面的な理由は、命令である。
\multicolumn{2}{c}{\thead{\makebox[0pt]{Arrangement Accuracy (\%)}}}
しかし、それはない命令\multicolumn
(投稿のタイトルから推測できる) が問題の原因です。 ではなく、 の使用が原因で\makebox[0pt]{...}
、LaTeX は実際に使用可能な幅 (2*2cm+2\tabcolsep) を考慮せずに行を下ります。 ヘッダー行が左側だけでなく両側に突出していることに注意してください。
とにかく、ヘッダーの設定を簡素化して、各S
型の列が の幅に渡るのに十分な幅を確保すべきだと思いますArrangement Accuracy (\%)
。ああ、そして を使用する(正当な)理由は見当たりません。太字ヘッダー行に -- 考慮しない限り読者に向かって叫ぶ正当な理由ではないと思います。(私はそうは思いません...)
\documentclass[12pt,oneside]{book}
%% Condensed preamble to the bare minimum:
\usepackage{geometry,{booktabs, ragged2e,siunitx}
\begin{document}
\begin{table}[h!]
\centering
\sisetup{table-format=6.4}
\begin{tabular}{@{} lSS @{}}
\toprule
Test Cases (Class A \& Class B) & \multicolumn{2}{c@{}}{Arrangement Accuracy (\%)}\\
\cmidrule(l){2-3}
& AM & FM \\
\midrule
Pairs of Samples 1 (A5 \& B42) & 333.33 & 1300.00 \\
Pairs of Samples 2 (A20 \& B44) & 47.44 & 77.35 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}