我有一个长表,最后一列太宽。我该如何修复这个表?
\documentclass[12pt, a4paper, onecolumn, oneside, final]{report}
\makeatother
\usepackage{array}
\setlength\extrarowheight{4pt}
\usepackage{tabto}
\newenvironment{tabs}[1]
{\TabPositions{#1}}
\usepackage{longtable}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{musicography}
\begin{document}
\begingroup
\setlength{\LTleft}{-20cm plus -1fill}
\setlength{\LTright}{\LTleft}
\begin{small}
\begin{longtable}{|p{1cm}|p{2cm}|p{2cm}|}
\caption{\textit{Pitch class} yang digunakan dalam penelitian}
\label{tbl:pitchClassUsed}\\
\hline
{\textbf{No}} & {\textbf{No. MIDI}} & {\textbf{\textit{Pitch Class}}} \bigstrut\\
\endfirsthead
\multicolumn{3}{c}{\textbf{\tablename~\thetable} \textit{Pitch class} yang digunakan dalam penelitian (Lanjutan)}\\
\hline
{\textbf{No}} & {\textbf{No. MIDI}} & {\textbf{\textit{Pitch Class}}} \bigstrut\\
\endhead
\hline
1 & 0 & \multicolumn{1}{l|}{0} \bigstrut\\
\hline
2 & 30 & F$\musSharp$1 / G$\flat$1 \bigstrut\\
\hline
3 & 31 & G1 \bigstrut\\
\hline
4 & 32 & G$\musSharp$1 / A$\flat$1 \bigstrut\\
\hline
5 & 33 & A1 \bigstrut\\
\hline
6 & 34 & A$\musSharp$1 / B$\flat$1 \bigstrut\\
\hline
7 & 35 & B1 \bigstrut\\
\hline
8 & 36 & C2 \bigstrut\\
\hline
9 & 37 & C$\musSharp$2 / D$\flat$2 \bigstrut\\
\hline
10 & 38 & D2 \bigstrut\\
\hline
11 & 39 & D$\musSharp$2 / E$\flat$2 \bigstrut\\
\hline
12 & 40 & E2 \bigstrut\\
\hline
13 & 41 & F2 \bigstrut\\
\hline
14 & 42 & F$\musSharp$2 / G$\flat$2 \bigstrut\\
\hline
15 & 43 & G2 \bigstrut\\
\hline
16 & 44 & G$\musSharp$2 / A$\flat$2 \bigstrut\\
\hline
17 & 45 & A2 \bigstrut\\
\hline
18 & 46 & A$\musSharp$2 / B$\flat$2 \bigstrut\\
\hline
19 & 47 & B2 \bigstrut\\
\hline
20 & 48 & C3 \bigstrut\\
\hline
21 & 49 & C$\musSharp$3 / D$\flat$3 \bigstrut\\
\hline
22 & 50 & D3 \bigstrut\\
\hline
23 & 51 & D$\musSharp$3 / E$\flat$3 \bigstrut\\
\hline
24 & 52 & E3 \bigstrut\\
\hline
25 & 53 & F3 \bigstrut\\
\hline
26 & 54 & F$\musSharp$3 / G$\flat$3 \bigstrut\\
\hline
27 & 55 & G3 \bigstrut\\
\hline
28 & 56 & G$\musSharp$3 / A$\flat$3 \bigstrut\\
\hline
29 & 57 & A3 \bigstrut\\
\hline
30 & 58 & A$\musSharp$3 / B$\flat$3 \bigstrut\\
\hline
31 & 59 & B3 \bigstrut\\
\hline
32 & 60 & C4 \bigstrut\\
\hline
33 & 61 & C$\musSharp$4 / D$\flat$4 \bigstrut\\
\hline
34 & 62 & D4 \bigstrut\\
\hline
35 & 63 & D$\musSharp$4 / E$\flat$4 \bigstrut\\
\hline
36 & 64 & E4 \bigstrut\\
\hline
37 & 65 & F4 \bigstrut\\
\hline
38 & 66 & F$\musSharp$4 / G$\flat$4 \bigstrut\\
\hline
39 & 67 & G4 \bigstrut\\
\hline
40 & 68 & G$\musSharp$4 / A$\flat$4 \bigstrut\\
\hline
41 & 69 & A4 \bigstrut\\
\hline
42 & 70 & A$\musSharp$4 / B$\flat$4 \bigstrut\\
\hline
43 & 71 & B4 \bigstrut\\
\hline
44 & 72 & C5 \bigstrut\\
\hline
45 & 73 & C$\musSharp$5 / D$\flat$5 \bigstrut\\
\hline
46 & 74 & D5 \bigstrut\\
\hline
47 & 76 & E5 \bigstrut\\
\hline
48 & 77 & F5 \bigstrut\\
\hline
49 & 81 & A5 \bigstrut\\
\hline
50 & 83 & B5 \bigstrut\\
\hline
51 & 85 & C$\musSharp$6 / D$\flat$6 \bigstrut\\
\hline
\end{longtable}%
\end{small}%
\end{document}
答案1
可以将标题文本重复到每一页,并且不会使第三列太宽,只需将标题文本设置为两行即可。该makecell
软件包允许这样做。
\documentclass[12pt, a4paper, onecolumn, oneside, final]{report}
\makeatother
\usepackage{array}
\setlength\extrarowheight{4pt}
\usepackage{tabto}
\newenvironment{tabs}[1]
{\TabPositions{#1}}
\usepackage{longtable}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{musicography}
\usepackage{bigstrut} % added <<<<<<<<<<<<
\usepackage{makecell} % added <<<<<<<<<<<<
\begin{document}
\setlength{\LTleft}{-20cm plus -1fill}
\setlength{\LTright}{\LTleft}
\begin{small}
\begin{longtable}{|p{1cm}|p{2cm}|p{4cm}|}
\caption{\textit{Pitch class} yang digunakan dalam penelitian}
\label{tbl:pitchClassUsed}\\
\hline
{\textbf{No}} & {\textbf{No. MIDI}} & {\textbf{\textit{Pitch Class}}} \bigstrut\\
\endfirsthead
% next line changed <<<<<<<<<<<<
\multicolumn{3}{c}{\makecell{\textbf{\tablename~\thetable} \textit{Pitch class} yang digunakan \\ dalam penelitian (Lanjutan)}}\\[12pt] % changed <<<<<<<<<<<<
\hline
{\textbf{No}} & {\textbf{No. MIDI}} & {\textbf{\textit{Pitch Class}}} \bigstrut\\
\endhead
\hline
1 & 0 & \multicolumn{1}{l|}{0} \bigstrut\\
\hline
2 & 30 & F$\musSharp$1 / G$\flat$1 \bigstrut\\
\hline
3 & 31 & G1 \bigstrut\\
\hline
4 & 32 & G$\musSharp$1 / A$\flat$1 \bigstrut\\
\hline
5 & 33 & A1 \bigstrut\\
\hline
6 & 34 & A$\musSharp$1 / B$\flat$1 \bigstrut\\
\hline
7 & 35 & B1 \bigstrut\\
\hline
8 & 36 & C2 \bigstrut\\
\hline
9 & 37 & C$\musSharp$2 / D$\flat$2 \bigstrut\\
\hline
10 & 38 & D2 \bigstrut\\
\hline
11 & 39 & D$\musSharp$2 / E$\flat$2 \bigstrut\\
\hline
12 & 40 & E2 \bigstrut\\
\hline
13 & 41 & F2 \bigstrut\\
\hline
14 & 42 & F$\musSharp$2 / G$\flat$2 \bigstrut\\
\hline
15 & 43 & G2 \bigstrut\\
\hline
16 & 44 & G$\musSharp$2 / A$\flat$2 \bigstrut\\
\hline
17 & 45 & A2 \bigstrut\\
\hline
18 & 46 & A$\musSharp$2 / B$\flat$2 \bigstrut\\
\hline
19 & 47 & B2 \bigstrut\\
\hline
20 & 48 & C3 \bigstrut\\
\hline
21 & 49 & C$\musSharp$3 / D$\flat$3 \bigstrut\\
\hline
22 & 50 & D3 \bigstrut\\
\hline
23 & 51 & D$\musSharp$3 / E$\flat$3 \bigstrut\\
\hline
24 & 52 & E3 \bigstrut\\
\hline
25 & 53 & F3 \bigstrut\\
\hline
26 & 54 & F$\musSharp$3 / G$\flat$3 \bigstrut\\
\hline
27 & 55 & G3 \bigstrut\\
\hline
28 & 56 & G$\musSharp$3 / A$\flat$3 \bigstrut\\
\hline
29 & 57 & A3 \bigstrut\\
\hline
30 & 58 & A$\musSharp$3 / B$\flat$3 \bigstrut\\
\hline
31 & 59 & B3 \bigstrut\\
\hline
32 & 60 & C4 \bigstrut\\
\hline
33 & 61 & C$\musSharp$4 / D$\flat$4 \bigstrut\\
\hline
34 & 62 & D4 \bigstrut\\
\hline
35 & 63 & D$\musSharp$4 / E$\flat$4 \bigstrut\\
\hline
36 & 64 & E4 \bigstrut\\
\hline
37 & 65 & F4 \bigstrut\\
\hline
38 & 66 & F$\musSharp$4 / G$\flat$4 \bigstrut\\
\hline
39 & 67 & G4 \bigstrut\\
\hline
40 & 68 & G$\musSharp$4 / A$\flat$4 \bigstrut\\
\hline
41 & 69 & A4 \bigstrut\\
\hline
42 & 70 & A$\musSharp$4 / B$\flat$4 \bigstrut\\
\hline
43 & 71 & B4 \bigstrut\\
\hline
44 & 72 & C5 \bigstrut\\
\hline
45 & 73 & C$\musSharp$5 / D$\flat$5 \bigstrut\\
\hline
46 & 74 & D5 \bigstrut\\
\hline
47 & 76 & E5 \bigstrut\\
\hline
48 & 77 & F5 \bigstrut\\
\hline
49 & 81 & A5 \bigstrut\\
\hline
50 & 83 & B5 \bigstrut\\
\hline
51 & 85 & C$\musSharp$6 / D$\flat$6 \bigstrut\\
\hline
\end{longtable}%
\end{small}%
\end{document}
笔记(与问题无关)
您可以通过将前两列居中来改善表格的外观。
添加 \newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
并使用 \begin{longtable}{|C{1cm}|C{2cm}|p{4cm}|}
更新
导致最后一列变宽的原因是原本要放置在下一页表格顶部的文本。
它不是一个“标题”,而是表格中的多列单元格,比三列的总宽度更宽。
不要重复标题文本,好像它是表格的开头,最好用它来将表格的这一部分与前一部分联系起来。还建议使用表脚来提醒读者这不是表格的结尾。
第三列现在可以更窄一些。
longtable
从这里开始
\begin{longtable}{|C{1cm}|C{2cm}|p{2.5cm}|}
\caption{\textit{Pitch class} yang digunakan dalam penelitian}
\label{tbl:pitchClassUsed}\\
\hline
{\textbf{No}} & {\textbf{No. MIDI}} & {\textbf{\textit{Pitch Class}}} \bigstrut\\
\endfirsthead
% next lines changed <<<<<<<<<<<<
\multicolumn{3}{c}{\textbf{\tablename~\thetable} \, \textit{\dots{} from the previous page}} \bigstrut\\
\hline
{\textbf{No}} & {\textbf{No. MIDI}} & {\textbf{\textit{Pitch Class}}} \bigstrut\\
\endhead
\multicolumn{3}{r}{\textit{continued on the next page \dots{} }}
\endfoot
\endlastfoot
%% ***************************************
\hline
1 & 0 & \multicolumn{1}{l|}{0} \bigstrut\\
...........
答案2
您可以通过确保整个表格适合单个页面来完全避免此问题。以下 MWE 展示了两种方法,即使不减小字体大小,也能轻松将表格放在单个页面上:
\documentclass[12pt, a4paper, onecolumn, oneside, final]{report}
\usepackage{musicography}
\usepackage{makecell}
\setcellgapes{5pt}
\usepackage{booktabs}
\begin{document}
\begin{table}
\makegapedcells
\caption{\textit{Pitch class} yang digunakan dalam penelitian}
\label{tbl:pitchClassUsed}
\begin{tabular}{|l|l|l| l|l|l|}
\hline
{\textbf{No}} & {\textbf{No. MIDI}} & {\textbf{\textit{Pitch Class}}} & {\textbf{No}} & {\textbf{No. MIDI}} & {\textbf{\textit{Pitch Class}}} \\
\hline
1 & 0 & \multicolumn{1}{l|}{0} & 27 & 55 & G3 \\
\hline
2 & 30 & F$\musSharp$1 / G$\flat$1 & 28 & 56 & G$\musSharp$3 / A$\flat$3 \\
\hline
3 & 31 & G1 & 29 & 57 & A3 \\
\hline
4 & 32 & G$\musSharp$1 / A$\flat$1 & 30 & 58 & A$\musSharp$3 / B$\flat$3 \\
\hline
5 & 33 & A1 & 31 & 59 & B3 \\
\hline
6 & 34 & A$\musSharp$1 / B$\flat$1 & 32 & 60 & C4 \\
\hline
7 & 35 & B1 & 33 & 61 & C$\musSharp$4 / D$\flat$4 \\
\hline
8 & 36 & C2 & 34 & 62 & D4 \\
\hline
9 & 37 & C$\musSharp$2 / D$\flat$2 & 35 & 63 & D$\musSharp$4 / E$\flat$4 \\
\hline
10 & 38 & D2 & 36 & 64 & E4 \\
\hline
11 & 39 & D$\musSharp$2 / E$\flat$2 & 37 & 65 & F4 \\
\hline
12 & 40 & E2 & 38 & 66 & F$\musSharp$4 / G$\flat$4 \\
\hline
13 & 41 & F2 & 39 & 67 & G4 \\
\hline
14 & 42 & F$\musSharp$2 / G$\flat$2 & 40 & 68 & G$\musSharp$4 / A$\flat$4 \\
\hline
15 & 43 & G2 & 41 & 69 & A4 \\
\hline
16 & 44 & G$\musSharp$2 / A$\flat$2 & 42 & 70 & A$\musSharp$4 / B$\flat$4 \\
\hline
17 & 45 & A2 & 43 & 71 & B4 \\
\hline
18 & 46 & A$\musSharp$2 / B$\flat$2 & 44 & 72 & C5 \\
\hline
19 & 47 & B2 & 45 & 73 & C$\musSharp$5 / D$\flat$5 \\
\hline
20 & 48 & C3 & 46 & 74 & D5 \\
\hline
21 & 49 & C$\musSharp$3 / D$\flat$3 & 47 & 76 & E5 \\
\hline
22 & 50 & D3 & 48 & 77 & F5 \\
\hline
23 & 51 & D$\musSharp$3 / E$\flat$3 & 49 & 81 & A5 \\
\hline
24 & 52 & E3 & 50 & 83 & B5 \\
\hline
25 & 53 & F3 & 51 & 85 & C$\musSharp$6 / D$\flat$6 \\
\hline
26 & 54 & F$\musSharp$3 / G$\flat$3 \\
\cline{1-3}
\end{tabular}
\end{table}%
\begin{table}
\caption{\textit{Pitch class} yang digunakan dalam penelitian}
\label{tbl:pitchClassUsed}
\begin{tabular}{@{}rcl@{\qquad}rcl @{\qquad}rcl@{}}
\toprule
\thead{No} & \thead{No.\\ MIDI} & \thead{Pitch Class} & \thead{No} & \thead{No.\\ MIDI} & \thead{Pitch Class} & \thead{No} & \thead{No.\\ MIDI} & \thead{Pitch Class} \\
\cmidrule(r{2em}){1-3} \cmidrule(r{2em}){4-6} \cmidrule{7-9}
1 & 0 & \multicolumn{1}{l}{0} & 18 & 46 & A$\musSharp$2 / B$\flat$2 & 35 & 63 & D$\musSharp$4 / E$\flat$4 \\
2 & 30 & F$\musSharp$1 / G$\flat$1 & 19 & 47 & B2 & 36 & 64 & E4 \\
3 & 31 & G1 & 20 & 48 & C3 & 37 & 65 & F4 \\
4 & 32 & G$\musSharp$1 / A$\flat$1 & 21 & 49 & C$\musSharp$3 / D$\flat$3 & 38 & 66 & F$\musSharp$4 / G$\flat$4 \\
5 & 33 & A1 & 22 & 50 & D3 & 39 & 67 & G4 \\ \addlinespace
6 & 34 & A$\musSharp$1 / B$\flat$1 & 23 & 51 & D$\musSharp$3 / E$\flat$3 & 40 & 68 & G$\musSharp$4 / A$\flat$4 \\
7 & 35 & B1 & 24 & 52 & E3 & 41 & 69 & A4 \\
8 & 36 & C2 & 25 & 53 & F3 & 42 & 70 & A$\musSharp$4 / B$\flat$4 \\
9 & 37 & C$\musSharp$2 / D$\flat$2 & 26 & 54 & F$\musSharp$3 / G$\flat$3 & 43 & 71 & B4 \\
10 & 38 & D2 & 27 & 55 & G3 & 44 & 72 & C5 \\ \addlinespace
11 & 39 & D$\musSharp$2 / E$\flat$2 & 28 & 56 & G$\musSharp$3 / A$\flat$3 & 45 & 73 & C$\musSharp$5 / D$\flat$5 \\
12 & 40 & E2 & 29 & 57 & A3 & 46 & 74 & D5 \\
13 & 41 & F2 & 30 & 58 & A$\musSharp$3 / B$\flat$3 & 47 & 76 & E5 \\
14 & 42 & F$\musSharp$2 / G$\flat$2 & 31 & 59 & B3 & 48 & 77 & F5 \\
15 & 43 & G2 & 32 & 60 & C4 & 49 & 81 & A5 \\ \addlinespace
16 & 44 & G$\musSharp$2 / A$\flat$2 & 33 & 61 & C$\musSharp$4 / D$\flat$4 & 50 & 83 & B5 \\
17 & 45 & A2 & 34 & 62 & D4 & 51 & 85 & C$\musSharp$6 / D$\flat$6 \\
\bottomrule
\end{tabular}
\end{table}%
\end{document}