\documentclass[11pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{array}
\usepackage{float}
\usepackage[export]{adjustbox}
\graphicspath{ {./images/} }
\usepackage{enumitem}
\usepackage{nameref}
\usepackage{amsfonts,amsmath,amssymb,amsthm,etoolbox}
\usepackage[version=4]{mhchem}
\usepackage{stmaryrd}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue, filecolor=magenta, urlcolor=cyan,}
\urlstyle{same}
\usepackage[vmargin=1.0in, left=1in, right=1.in,
footskip=2.0cm, % footskip margin
]{geometry}
\begin{document}
\begin{table}[]
\caption{}
\label{tab:my-table}
\begin{tabular}{llllllllll}
\multirow{3}{*}{Chrom Length} & \multicolumn{9}{l}{Success Rate (\%)} \\
& \multicolumn{3}{l}{SRP 1} & \multicolumn{3}{l}{SRP 2} & \multicolumn{3}{l}{SRP 3} \\
& Contr. Opr. & Slice Cross. & Comb. & Contr. Opr. & Slice Cross. & Comb. & Contr. Opr. & Slice Cross. & Comb. \\
11 & 40 & 88 & 85 & 0 & 0 & 0 & 5 & 3 & 8 \\
\multirow{3}{*}{15} & 56 & 94 & 97 & 0 & 0 & 0 & 4 & 10 & 5 \\
& 61 & 99 & 100 & 0 & 7 & 6 & 3 & 6 & 13 \\
& 62 & 100 & 98 & 0 & 23 & 21 & 5 & 8 & 12 \\
\multirow{3}{*}{27} & 58 & 97 & 100 & 0 & 38 & 37 & 3 & 13 & 14 \\
& 65 & 100 & 98 & 2 & 41 & 44 & 4 & 14 & 13 \\
& 69 & 99 & 99 & 6 & 52 & 42 & 7 & 7 & 10 \\
39 & 72 & 97 & 99 & 10 & 49 & 57 & 7 & 8 & 8 \\
43 & 74 & 94 & 96 & 7 & 57 & 59 & 3 & 12 & 8 \\
47 & 66 & 94 & 95 & 9 & 49 & 62 & 5 & 11 & 13 \\
51 & 79 & 97 & 94 & 10 & 62 & 61 & 5 & 8 & 9 \\
55 & 80 & 96 & 97 & 11 & 70 & 58 & 5 & 7 & 6 \\
59 & 73 & 96 & 98 & 12 & 59 & 51 & 0 & 7 & 10 \\
63 & 75 & 98 & 95 & 17 & 60 & 68 & 3 & 8 & 7 \\
67 & 74 & 99 & 96 & 21 & 66 & 63 & 4 & 8 & 4 \\
71 & 78 & 98 & 93 & 20 & 59 & 68 & 0 & 3 & 4 \\
75 & 75 & 96 & 96 & 16 & 61 & 72 & 3 & 3 & 9 \\
79 & 78 & 100 & 99 & 16 & 61 & 58 & 1 & 8 & 8 \\
83 & 69 & 96 & 98 & 18 & 74 & 71 & 1 & 5 & 11 \\
87 & 77 & 94 & 98 & 24 & 70 & 56 & 1 & 7 & 9 \\
91 & 72 & 97 & 92 & 20 & 67 & 68 & 4 & 5 & 4 \\
95 & 76 & 97 & 93 & 20 & 52 & 61 & 0 & 7 & 8 \\
99 & 82 & 91 & 95 & 24 & 68 & 63 & 4 & 4 & 2 \\
103 & 77 & 94 & 98 & 25 & 56 & 61 & 1 & 7 & 6 \\
Average & 70.33 & 96.29 & 96.21 & 12.00 & 50.04 & 50.29 & 3.25 & 7.46 & 8.38
\end{tabular}
\end{table}
\end{document}
答案1
像这样?
(红线显示页面布局)
- 列标题太宽,请分成两行写!
- 通过使用
tblr
库tabularray
和booktabs
:siunitx
\documentclass[11pt,a4paper]{report}
\usepackage[margin=1.0in,
footskip=2.0cm, % footskip margin
]{geometry}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum} % for dummy text
%---------------------------------------------------------------%
\usepackage[T1]{fontenc}
\usepackage[skip=1ex]{caption}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\begin{document}
\lipsum[66]
\begin{table}[ht]
\caption{}
\label{tab:my-table}
\begin{tblr}{colspec = {@{} *{2}{X[c, si={table-format=2.0}]}
*{2}{X[c, si={table-format=3.0}]}
*{6}{X[c, si={table-format=2.0}]}
@{} },
cell{2}{2,5,8} = {c=3}{c},
row{1-3,Z} = {guard,b},
rowsep = 1pt
}
\toprule
\SetCell[r=3]{l} Chrome Length
& \SetCell[c=9]{c} Source rate
& & & & & & & & \\
\cmidrule{2-10}
& SRP 1
& & & SRP 2
& & & SRP 2
& & \\
\cmidrule[lr]{2-4}
\cmidrule[lr]{5-7}
\cmidrule[lr]{8-10}
& Contr. Opr. & Slice Cross. & Comb.
& Contr. Opr. & Slice Cross. & Comb.
& Contr. Opr. & Slice Cross. & Comb. \\
\midrule
11 & 40 & 88 & 85 & 0 & 0 & 0 & 5 & 3 & 8 \\
\midrule[dashed, 0.15pt]
& 56 & 94 & 97 & 0 & 0 & 0 & 4 & 10 & 5 \\
15 & 61 & 99 & 100 & 0 & 7 & 6 & 3 & 6 & 13 \\
& 62 & 100 & 98 & 0 & 23 & 21 & 5 & 8 & 12 \\
\midrule[dashed, 0.15pt]
& 58 & 97 & 100 & 0 & 38 & 37 & 3 & 13 & 14 \\
27 & 65 & 100 & 98 & 2 & 41 & 44 & 4 & 14 & 13 \\
& 69 & 99 & 99 & 6 & 52 & 42 & 7 & 7 & 10 \\
\midrule[dashed, 0.15pt]
39 & 72 & 97 & 99 & 10 & 49 & 57 & 7 & 8 & 8 \\
43 & 74 & 94 & 96 & 7 & 57 & 59 & 3 & 12 & 8 \\
47 & 66 & 94 & 95 & 9 & 49 & 62 & 5 & 11 & 13 \\
51 & 79 & 97 & 94 & 10 & 62 & 61 & 5 & 8 & 9 \\
55 & 80 & 96 & 97 & 11 & 70 & 58 & 5 & 7 & 6 \\
59 & 73 & 96 & 98 & 12 & 59 & 51 & 0 & 7 & 10 \\
63 & 75 & 98 & 95 & 17 & 60 & 68 & 3 & 8 & 7 \\
67 & 74 & 99 & 96 & 21 & 66 & 63 & 4 & 8 & 4 \\
71 & 78 & 98 & 93 & 20 & 59 & 68 & 0 & 3 & 4 \\
75 & 75 & 96 & 96 & 16 & 61 & 72 & 3 & 3 & 9 \\
79 & 78 & 100 & 99 & 16 & 61 & 58 & 1 & 8 & 8 \\
83 & 69 & 96 & 98 & 18 & 74 & 71 & 1 & 5 & 11 \\
87 & 77 & 94 & 98 & 24 & 70 & 56 & 1 & 7 & 9 \\
91 & 72 & 97 & 92 & 20 & 67 & 68 & 4 & 5 & 4 \\
95 & 76 & 97 & 93 & 20 & 52 & 61 & 0 & 7 & 8 \\
99 & 82 & 91 & 95 & 24 & 68 & 63 & 4 & 4 & 2 \\
103 & 77 & 94 & 98 & 25 & 56 & 61 & 1 & 7 & 6 \\
Average
& 70.33 & 96.29 & 96.21 & 12.00 & 50.04 & 50.29 & 3.25 & 7.46 & 8.38 \\
\bottomrule
\end{tblr}
\end{table}
\lipsum[66]
\end{document}
答案2
这是一个利用表格型包以确保表格适合文本块的宽度。通过X
在所有十列中使用列类型,LaTeX 可以在需要时在单元格中插入换行符。
另外,我还会使用书签包提供一些额外的视觉结构,既在表头行中,也在表体中。具体请参见\addlinespace
以下代码中指令的使用,以提供一些(希望有帮助的)视觉节奏。
\documentclass[11pt,a4paper]{report}
%%\usepackage[utf8]{inputenc} % that's the default nowadays
\usepackage[T1]{fontenc}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{array}
\usepackage{float}
\usepackage[export]{adjustbox}
\graphicspath{ {./images/} }
\usepackage{enumitem}
\usepackage{nameref}
\usepackage{%amsfonts, % is loaded automatically by 'amssymb'
amsmath,amssymb,amsthm,etoolbox}
\usepackage[version=4]{mhchem}
\usepackage{stmaryrd}
\usepackage{hyperref}
\usepackage{xurl}
\urlstyle{same}
\hypersetup{colorlinks=true, linkcolor=blue,
filecolor=magenta, urlcolor=cyan}
\usepackage[margin=1in, footskip=2cm]{geometry}
%% New code
\usepackage{tabularx,ragged2e,booktabs}
\newcolumntype{L}{>{\RaggedRight}X}
\newcolumntype{C}{>{\Centering}X}
\newcommand\mytab[1]{\smash[b]{%
\begin{tabular}[t]{@{}p{\hsize}@{}} #1 \end{tabular}}}
\begin{document}
\begin{table}[ht]
\caption{A ten-column table\strut}
\label{tab:my-table}
\begin{tabularx}{\textwidth}{@{} L *{9}{C} @{}}
\toprule
\mytab{Chrom Length} & \multicolumn{9}{c@{}}{Success Rate (\%)}\\
\cmidrule(l){2-10}
& \multicolumn{3}{c}{SRP 1}
& \multicolumn{3}{c}{SRP 2}
& \multicolumn{3}{c@{}}{SRP 3} \\
\cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(l){8-10}
& Contr.\ Opr. & Slice Cross. & Comb.
& Contr.\ Opr. & Slice Cross. & Comb.
& Contr.\ Opr. & Slice Cross. & Comb. \\
\midrule
11 & 40 & 88 & 85 & 0 & 0 & 0 & 5 & 3 & 8 \\
\addlinespace
\multirow{3}{*}{15}
& 56 & 94 & 97 & 0 & 0 & 0 & 4 & 10 & 5 \\
& 61 & 99 & 100 & 0 & 7 & 6 & 3 & 6 & 13 \\
& 62 & 100 & 98 & 0 & 23 & 21 & 5 & 8 & 12 \\
\addlinespace
\multirow{3}{*}{27}
& 58 & 97 & 100 & 0 & 38 & 37 & 3 & 13 & 14 \\
& 65 & 100 & 98 & 2 & 41 & 44 & 4 & 14 & 13 \\
& 69 & 99 & 99 & 6 & 52 & 42 & 7 & 7 & 10 \\
\addlinespace
39 & 72 & 97 & 99 & 10 & 49 & 57 & 7 & 8 & 8 \\
43 & 74 & 94 & 96 & 7 & 57 & 59 & 3 & 12 & 8 \\
47 & 66 & 94 & 95 & 9 & 49 & 62 & 5 & 11 & 13 \\
51 & 79 & 97 & 94 & 10 & 62 & 61 & 5 & 8 & 9 \\
55 & 80 & 96 & 97 & 11 & 70 & 58 & 5 & 7 & 6 \\
\addlinespace
59 & 73 & 96 & 98 & 12 & 59 & 51 & 0 & 7 & 10 \\
63 & 75 & 98 & 95 & 17 & 60 & 68 & 3 & 8 & 7 \\
67 & 74 & 99 & 96 & 21 & 66 & 63 & 4 & 8 & 4 \\
71 & 78 & 98 & 93 & 20 & 59 & 68 & 0 & 3 & 4 \\
75 & 75 & 96 & 96 & 16 & 61 & 72 & 3 & 3 & 9 \\
\addlinespace
79 & 78 & 100 & 99 & 16 & 61 & 58 & 1 & 8 & 8 \\
83 & 69 & 96 & 98 & 18 & 74 & 71 & 1 & 5 & 11 \\
87 & 77 & 94 & 98 & 24 & 70 & 56 & 1 & 7 & 9 \\
91 & 72 & 97 & 92 & 20 & 67 & 68 & 4 & 5 & 4 \\
95 & 76 & 97 & 93 & 20 & 52 & 61 & 0 & 7 & 8 \\
\addlinespace
99 & 82 & 91 & 95 & 24 & 68 & 63 & 4 & 4 & 2 \\
103 & 77 & 94 & 98 & 25 & 56 & 61 & 1 & 7 & 6 \\
\midrule
Average & 70.33 & 96.29 & 96.21 & 12.00 & 50.04 & 50.29 & 3.25 & 7.46 & 8.38 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
答案3
我不会\multirow
对 15 和 27 组使用:输出会非常模糊。第一列中一个单元格后面的空单元格将被解释为“重复上一个值”。
siunitx
此外,我还会使用booktabs
来改善外观。该\splitcell
命令有助于设置复杂单元格;*
-variant 也适用\smash
。
提供标题文字:您的读者会欣赏的。
\documentclass[11pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[
vmargin=1.0in,
left=1in,
right=1.in,
footskip=2.0cm, % footskip margin
]{geometry}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{graphicx}
\usepackage{array}
\usepackage[export]{adjustbox}
\usepackage{enumitem}
\usepackage{nameref}
\usepackage{caption}
\usepackage{amsfonts,amsmath,amssymb,amsthm,etoolbox}
\usepackage[version=4]{mhchem}
\usepackage{stmaryrd}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue, filecolor=magenta, urlcolor=cyan,}
\urlstyle{same}
\graphicspath{ {./images/} }
\NewDocumentCommand{\splitcell}{sm}{%
\IfBooleanT{#1}{\smash}{\begin{tabular}[t]{@{}c@{}}#2\end{tabular}}%
}
\begin{document}
\begin{table}[htp]
\caption{A caption here, please}
\label{tab:my-table}
\begin{tabular}{
@{}
S[table-format=3.0]
S[table-format=2.0]
S[table-format=3.0]
S[table-format=3.0]
S[table-format=2.0]
S[table-format=2.0]
S[table-format=2.0]
S[table-format=2.0]
S[table-format=2.0]
S[table-format=2.0]
@{}
}
\toprule
\splitcell*{Chrom \\ Length} & \multicolumn{9}{c}{Success Rate (\%)} \\
\cmidrule(l){2-10}
& \multicolumn{3}{c}{SRP 1} & \multicolumn{3}{c}{SRP 2} & \multicolumn{3}{c}{SRP 3} \\
\cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(l){8-10}
& \splitcell{Contr. \\ Opr.} & \splitcell{Slice \\ Cross.} & {Comb.}
& \splitcell{Contr. \\ Opr.} & \splitcell{Slice \\ Cross.} & {Comb.}
& \splitcell{Contr. \\ Opr.} & \splitcell{Slice \\ Cross.} & {Comb.} \\
\midrule
11 & 40 & 88 & 85 & 0 & 0 & 0 & 5 & 3 & 8 \\
15 & 56 & 94 & 97 & 0 & 0 & 0 & 4 & 10 & 5 \\
& 61 & 99 & 100 & 0 & 7 & 6 & 3 & 6 & 13 \\
& 62 & 100 & 98 & 0 & 23 & 21 & 5 & 8 & 12 \\
27 & 58 & 97 & 100 & 0 & 38 & 37 & 3 & 13 & 14 \\
& 65 & 100 & 98 & 2 & 41 & 44 & 4 & 14 & 13 \\
& 69 & 99 & 99 & 6 & 52 & 42 & 7 & 7 & 10 \\
39 & 72 & 97 & 99 & 10 & 49 & 57 & 7 & 8 & 8 \\
43 & 74 & 94 & 96 & 7 & 57 & 59 & 3 & 12 & 8 \\
47 & 66 & 94 & 95 & 9 & 49 & 62 & 5 & 11 & 13 \\
51 & 79 & 97 & 94 & 10 & 62 & 61 & 5 & 8 & 9 \\
55 & 80 & 96 & 97 & 11 & 70 & 58 & 5 & 7 & 6 \\
59 & 73 & 96 & 98 & 12 & 59 & 51 & 0 & 7 & 10 \\
63 & 75 & 98 & 95 & 17 & 60 & 68 & 3 & 8 & 7 \\
67 & 74 & 99 & 96 & 21 & 66 & 63 & 4 & 8 & 4 \\
71 & 78 & 98 & 93 & 20 & 59 & 68 & 0 & 3 & 4 \\
75 & 75 & 96 & 96 & 16 & 61 & 72 & 3 & 3 & 9 \\
79 & 78 & 100 & 99 & 16 & 61 & 58 & 1 & 8 & 8 \\
83 & 69 & 96 & 98 & 18 & 74 & 71 & 1 & 5 & 11 \\
87 & 77 & 94 & 98 & 24 & 70 & 56 & 1 & 7 & 9 \\
91 & 72 & 97 & 92 & 20 & 67 & 68 & 4 & 5 & 4 \\
95 & 76 & 97 & 93 & 20 & 52 & 61 & 0 & 7 & 8 \\
99 & 82 & 91 & 95 & 24 & 68 & 63 & 4 & 4 & 2 \\
103 & 77 & 94 & 98 & 25 & 56 & 61 & 1 & 7 & 6 \\
\midrule
{Average} & {70.33} & {96.29} & {96.21} & {12.00} & {50.04} & {50.29} & {3.25} & {7.46} & {8.38} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}