![表格中一行中有多个多列的问题](https://linux22.com/image/410826/%E8%A1%A8%E6%A0%BC%E4%B8%AD%E4%B8%80%E8%A1%8C%E4%B8%AD%E6%9C%89%E5%A4%9A%E4%B8%AA%E5%A4%9A%E5%88%97%E7%9A%84%E9%97%AE%E9%A2%98.png)
如何删除最左边第一个没有内容的多列,同时其他多列保持原样?这是我的代码:
\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{siunitx}
\begin{document}
\begin{table}[htpb]
\centering
\begin{adjustbox}{max width =\textwidth}
\begin{tabular}{|>{\bfseries}l|*{16}{l|}}
\hline
\multicolumn{1}{c|}{} & % The multicolumn in question
\multicolumn{2}{c|}{\textbf{1. Oktave}} &
\multicolumn{2}{c|}{\textbf{2. Oktave}} &
\multicolumn{2}{c|}{\textbf{3. Oktave}} &
\multicolumn{2}{c|}{\textbf{4. Oktave}} &
\multicolumn{2}{c|}{\textbf{5. Oktave}} &
\multicolumn{2}{c|}{\textbf{6. Oktave}} &
\multicolumn{2}{c|}{\textbf{7. Oktave}} &
\multicolumn{2}{c|}{\textbf{8. Oktave}} \\ \hline
Ton & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz \\ \hline
$\boldsymbol{A}$ & 0 & 27,500 & 12 & 55,000 & 24 & 110,000 & 36 & 220,000 & 48 & 440,000 & 60 & 880,000 & 72 & 1760,000 & 84 & 3520,000 \\
$\boldsymbol{A\sharp /B\flat}$ & 1 & 29,135 & 13 & 58,270 & 25 & 116,541 & 37 & 233,082 & 49 & 466,164 & 61 & 932,328 & 73 & 1864,655 & 85 & 3729,310 \\
$\boldsymbol{B}$ & 2 & 30,868 & 14 & 61,735 & 26 & 123,471 & 38 & 246,942 & 50 & 493,883 & 62 & 987,767 & 74 & 1975,533 & 86 & 3951,066 \\
$\boldsymbol{C}$ & 3 & 32,703 & 15 & 65,406 & 27 & 130,813 & 39 & 261,626 & 51 & 523,251 & 63 & 1046,502 & 75 & 2093,005 & 87 & 4186,009 \\
$\boldsymbol{C\sharp/D\flat}$ & 4 & 34,648 & 16 & 69,296 & 28 & 138,591 & 40 & 277,183 & 52 & 554,365 & 64 & 1108,731 & 76 & 2217,461 & & \\
$\boldsymbol{D}$ & 5 & 36,708 & 17 & 73,416 & 29 & 146,832 & 41 & 293,665 & 53 & 587,330 & 65 & 1174,659 & 77 & 2349,318 & & \\
$\boldsymbol{D\sharp/E\flat}$ & 6 & 38,891 & 18 & 77,782 & 30 & 155,563 & 42 & 311,127 & 54 & 622,254 & 66 & 1244,508 & 78 & 2489,016 & & \\
$\boldsymbol{E}$ & 7 & 41.203 & 19 & 82,407 & 31 & 164,814 & 43 & 329,628 & 55 & 659,255 & 67 & 1318,510 & 79 & 2637,021 & & \\
$\boldsymbol{F}$ & 8 & 43,654 & 20 & 87,307 & 32 & 174,614 & 44 & 349,228 & 56 & 698,456 & 68 & 1396,913 & 80 & 2793,826 & & \\
$\boldsymbol{F\sharp/G\flat}$ & 9 & 46,249 & 21 & 92,499 & 33 & 184,997 & 45 & 369,994 & 57 & 739,989 & 69 & 1479,978 & 81 & 2959,955 & & \\
$\boldsymbol{G}$ & 10 & 48,999 & 22 & 97,999 & 34 & 195,998 & 46 & 391,995 & 58 & 783,991 & 70 & 1567,982 & 82 & 3135,964 & & \\
$\boldsymbol{G\sharp/A\flat}$ & 11 & 51,913 & 23 & 103,826 & 35 & 207,652 & 47 & 415,305 & 59 & 830,609 & 71 & 1661,219 & 83 & 3322,438 & & \\ \hline
\end{tabular}
\end{adjustbox}
\end{table}
\end{document}
答案1
我猜你正在寻找\cline{<start column>-<end column>}
。与 形成对比的是,从列到\hline
\cline
绘制一条水平线:<start column>
<end column>
\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{siunitx}
\begin{document}
\begin{table}[htpb]
\centering
\begin{adjustbox}{max width =\textwidth}
\begin{tabular}{|>{\bfseries}l|*{16}{l|}}
\cline{2-17}
\multicolumn{1}{c|}{} & % The multicolumn in question
\multicolumn{2}{c|}{\textbf{1. Oktave}} &
\multicolumn{2}{c|}{\textbf{2. Oktave}} &
\multicolumn{2}{c|}{\textbf{3. Oktave}} &
\multicolumn{2}{c|}{\textbf{4. Oktave}} &
\multicolumn{2}{c|}{\textbf{5. Oktave}} &
\multicolumn{2}{c|}{\textbf{6. Oktave}} &
\multicolumn{2}{c|}{\textbf{7. Oktave}} &
\multicolumn{2}{c|}{\textbf{8. Oktave}} \\ \hline
Ton & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz \\ \hline
$\boldsymbol{A}$ & 0 & 27,500 & 12 & 55,000 & 24 & 110,000 & 36 & 220,000 & 48 & 440,000 & 60 & 880,000 & 72 & 1760,000 & 84 & 3520,000 \\
$\boldsymbol{A\sharp /B\flat}$ & 1 & 29,135 & 13 & 58,270 & 25 & 116,541 & 37 & 233,082 & 49 & 466,164 & 61 & 932,328 & 73 & 1864,655 & 85 & 3729,310 \\
$\boldsymbol{B}$ & 2 & 30,868 & 14 & 61,735 & 26 & 123,471 & 38 & 246,942 & 50 & 493,883 & 62 & 987,767 & 74 & 1975,533 & 86 & 3951,066 \\
$\boldsymbol{C}$ & 3 & 32,703 & 15 & 65,406 & 27 & 130,813 & 39 & 261,626 & 51 & 523,251 & 63 & 1046,502 & 75 & 2093,005 & 87 & 4186,009 \\
$\boldsymbol{C\sharp/D\flat}$ & 4 & 34,648 & 16 & 69,296 & 28 & 138,591 & 40 & 277,183 & 52 & 554,365 & 64 & 1108,731 & 76 & 2217,461 & & \\
$\boldsymbol{D}$ & 5 & 36,708 & 17 & 73,416 & 29 & 146,832 & 41 & 293,665 & 53 & 587,330 & 65 & 1174,659 & 77 & 2349,318 & & \\
$\boldsymbol{D\sharp/E\flat}$ & 6 & 38,891 & 18 & 77,782 & 30 & 155,563 & 42 & 311,127 & 54 & 622,254 & 66 & 1244,508 & 78 & 2489,016 & & \\
$\boldsymbol{E}$ & 7 & 41.203 & 19 & 82,407 & 31 & 164,814 & 43 & 329,628 & 55 & 659,255 & 67 & 1318,510 & 79 & 2637,021 & & \\
$\boldsymbol{F}$ & 8 & 43,654 & 20 & 87,307 & 32 & 174,614 & 44 & 349,228 & 56 & 698,456 & 68 & 1396,913 & 80 & 2793,826 & & \\
$\boldsymbol{F\sharp/G\flat}$ & 9 & 46,249 & 21 & 92,499 & 33 & 184,997 & 45 & 369,994 & 57 & 739,989 & 69 & 1479,978 & 81 & 2959,955 & & \\
$\boldsymbol{G}$ & 10 & 48,999 & 22 & 97,999 & 34 & 195,998 & 46 & 391,995 & 58 & 783,991 & 70 & 1567,982 & 82 & 3135,964 & & \\
$\boldsymbol{G\sharp/A\flat}$ & 11 & 51,913 & 23 & 103,826 & 35 & 207,652 & 47 & 415,305 & 59 & 830,609 & 71 & 1661,219 & 83 & 3322,438 & & \\ \hline
\end{tabular}
\end{adjustbox}
\end{table}
\end{document}
改进
为了使您的表格看起来更有吸引力,您应该考虑添加booktabs
和cellspace
包提供的功能。
单元格空间
使用cellspace
可以自定义单元格的垂直间距。内容与单元格顶部或底部之间的所需间距由\cellspacetoplimit
和决定\cellspacebottomlimit
。
仅当列类型前面附加了特殊修饰符时,更改才会生效。默认情况下,修饰符是单个字符S
在您的情况下,S
与S
引入的 -column 类型发生冲突。要解决和siunitx
之间的冲突,您可以选择不同的修饰符。要将修饰符从 更改为例如,您必须调用。siunitx
cellspace
S
O
\usepackage[column=O]{cellspace}
在您的情况下,您不仅需要修改表序言中的列类型,还需要修改\multicolumn
命令中的列类型。
下面的例子可以说明这一点。
\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{siunitx}
\usepackage[column=O]{cellspace}
\setlength\cellspacetoplimit{0.5em}
\setlength\cellspacebottomlimit{0.5em}
\begin{document}
\begin{table}[htpb]
\centering
\begin{adjustbox}{max width =\textwidth}
\begin{tabular}{|>{\bfseries}O{l}|*{16}{O{l}|}}
\cline{2-17}
\multicolumn{1}{O{c}|}{} & % The multicolumn in question
\multicolumn{2}{O{c}|}{\textbf{1. Oktave}} &
\multicolumn{2}{O{c}|}{\textbf{2. Oktave}} &
\multicolumn{2}{O{c}|}{\textbf{3. Oktave}} &
\multicolumn{2}{O{c}|}{\textbf{4. Oktave}} &
\multicolumn{2}{O{c}|}{\textbf{5. Oktave}} &
\multicolumn{2}{O{c}|}{\textbf{6. Oktave}} &
\multicolumn{2}{O{c}|}{\textbf{7. Oktave}} &
\multicolumn{2}{O{c}|}{\textbf{8. Oktave}} \\ \hline
Ton & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz \\ \hline
$\boldsymbol{A}$ & 0 & 27,500 & 12 & 55,000 & 24 & 110,000 & 36 & 220,000 & 48 & 440,000 & 60 & 880,000 & 72 & 1760,000 & 84 & 3520,000 \\
$\boldsymbol{A\sharp /B\flat}$ & 1 & 29,135 & 13 & 58,270 & 25 & 116,541 & 37 & 233,082 & 49 & 466,164 & 61 & 932,328 & 73 & 1864,655 & 85 & 3729,310 \\
$\boldsymbol{B}$ & 2 & 30,868 & 14 & 61,735 & 26 & 123,471 & 38 & 246,942 & 50 & 493,883 & 62 & 987,767 & 74 & 1975,533 & 86 & 3951,066 \\
$\boldsymbol{C}$ & 3 & 32,703 & 15 & 65,406 & 27 & 130,813 & 39 & 261,626 & 51 & 523,251 & 63 & 1046,502 & 75 & 2093,005 & 87 & 4186,009 \\
$\boldsymbol{C\sharp/D\flat}$ & 4 & 34,648 & 16 & 69,296 & 28 & 138,591 & 40 & 277,183 & 52 & 554,365 & 64 & 1108,731 & 76 & 2217,461 & & \\
$\boldsymbol{D}$ & 5 & 36,708 & 17 & 73,416 & 29 & 146,832 & 41 & 293,665 & 53 & 587,330 & 65 & 1174,659 & 77 & 2349,318 & & \\
$\boldsymbol{D\sharp/E\flat}$ & 6 & 38,891 & 18 & 77,782 & 30 & 155,563 & 42 & 311,127 & 54 & 622,254 & 66 & 1244,508 & 78 & 2489,016 & & \\
$\boldsymbol{E}$ & 7 & 41.203 & 19 & 82,407 & 31 & 164,814 & 43 & 329,628 & 55 & 659,255 & 67 & 1318,510 & 79 & 2637,021 & & \\
$\boldsymbol{F}$ & 8 & 43,654 & 20 & 87,307 & 32 & 174,614 & 44 & 349,228 & 56 & 698,456 & 68 & 1396,913 & 80 & 2793,826 & & \\
$\boldsymbol{F\sharp/G\flat}$ & 9 & 46,249 & 21 & 92,499 & 33 & 184,997 & 45 & 369,994 & 57 & 739,989 & 69 & 1479,978 & 81 & 2959,955 & & \\
$\boldsymbol{G}$ & 10 & 48,999 & 22 & 97,999 & 34 & 195,998 & 46 & 391,995 & 58 & 783,991 & 70 & 1567,982 & 82 & 3135,964 & & \\
$\boldsymbol{G\sharp/A\flat}$ & 11 & 51,913 & 23 & 103,826 & 35 & 207,652 & 47 & 415,305 & 59 & 830,609 & 71 & 1661,219 & 83 & 3322,438 & & \\ \hline
\end{tabular}
\end{adjustbox}
\end{table}
\end{document}
Cellspace 和 Booktabs
为了使布局更具吸引力,您还可以遵循包装的指南booktabs
。
\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage[column=O]{cellspace}
\setlength\cellspacetoplimit{0.5em}
\setlength\cellspacebottomlimit{0.5em}
\begin{document}
\begin{table}[htpb]
\centering
\begin{adjustbox}{max width =\textwidth}
\begin{tabular}{>{\bfseries}O{l}*{16}{O{l}}}
\toprule
\multicolumn{1}{O{c}}{} & % The multicolumn in question
\multicolumn{2}{O{c}}{\textbf{1. Oktave}} &
\multicolumn{2}{O{c}}{\textbf{2. Oktave}} &
\multicolumn{2}{O{c}}{\textbf{3. Oktave}} &
\multicolumn{2}{O{c}}{\textbf{4. Oktave}} &
\multicolumn{2}{O{c}}{\textbf{5. Oktave}} &
\multicolumn{2}{O{c}}{\textbf{6. Oktave}} &
\multicolumn{2}{O{c}}{\textbf{7. Oktave}} &
\multicolumn{2}{O{c}}{\textbf{8. Oktave}} \\
\cmidrule(r{0.4em}){2-3}
\cmidrule(l{0.4em}r{0.4em}){4-5}
\cmidrule(l{0.4em}r{0.4em}){6-7}
\cmidrule(l{0.4em}r{0.4em}){8-9}
\cmidrule(l{0.4em}r{0.4em}){10-11}
\cmidrule(l{0.4em}r{0.4em}){12-13}
\cmidrule(l{0.4em}r{0.4em}){14-15}
\cmidrule(l{0.4em}){16-17}
Ton & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz & $n$ & Hertz \\ \midrule
$\boldsymbol{A}$ & 0 & 27,500 & 12 & 55,000 & 24 & 110,000 & 36 & 220,000 & 48 & 440,000 & 60 & 880,000 & 72 & 1760,000 & 84 & 3520,000 \\
$\boldsymbol{A\sharp /B\flat}$ & 1 & 29,135 & 13 & 58,270 & 25 & 116,541 & 37 & 233,082 & 49 & 466,164 & 61 & 932,328 & 73 & 1864,655 & 85 & 3729,310 \\
$\boldsymbol{B}$ & 2 & 30,868 & 14 & 61,735 & 26 & 123,471 & 38 & 246,942 & 50 & 493,883 & 62 & 987,767 & 74 & 1975,533 & 86 & 3951,066 \\
$\boldsymbol{C}$ & 3 & 32,703 & 15 & 65,406 & 27 & 130,813 & 39 & 261,626 & 51 & 523,251 & 63 & 1046,502 & 75 & 2093,005 & 87 & 4186,009 \\
$\boldsymbol{C\sharp/D\flat}$ & 4 & 34,648 & 16 & 69,296 & 28 & 138,591 & 40 & 277,183 & 52 & 554,365 & 64 & 1108,731 & 76 & 2217,461 & & \\
$\boldsymbol{D}$ & 5 & 36,708 & 17 & 73,416 & 29 & 146,832 & 41 & 293,665 & 53 & 587,330 & 65 & 1174,659 & 77 & 2349,318 & & \\
$\boldsymbol{D\sharp/E\flat}$ & 6 & 38,891 & 18 & 77,782 & 30 & 155,563 & 42 & 311,127 & 54 & 622,254 & 66 & 1244,508 & 78 & 2489,016 & & \\
$\boldsymbol{E}$ & 7 & 41.203 & 19 & 82,407 & 31 & 164,814 & 43 & 329,628 & 55 & 659,255 & 67 & 1318,510 & 79 & 2637,021 & & \\
$\boldsymbol{F}$ & 8 & 43,654 & 20 & 87,307 & 32 & 174,614 & 44 & 349,228 & 56 & 698,456 & 68 & 1396,913 & 80 & 2793,826 & & \\
$\boldsymbol{F\sharp/G\flat}$ & 9 & 46,249 & 21 & 92,499 & 33 & 184,997 & 45 & 369,994 & 57 & 739,989 & 69 & 1479,978 & 81 & 2959,955 & & \\
$\boldsymbol{G}$ & 10 & 48,999 & 22 & 97,999 & 34 & 195,998 & 46 & 391,995 & 58 & 783,991 & 70 & 1567,982 & 82 & 3135,964 & & \\
$\boldsymbol{G\sharp/A\flat}$ & 11 & 51,913 & 23 & 103,826 & 35 & 207,652 & 47 & 415,305 & 59 & 830,609 & 71 & 1661,219 & 83 & 3322,438 & & \\ \bottomrule
\end{tabular}
\end{adjustbox}
\end{table}
\end{document}