這是代碼。正如您所看到的,該表存在幾個問題。我真的不知道如何讓這些行消失並將整個表格帶到第一頁。謝謝!
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[table]{xcolor}
\usepackage[showframe=true]{geometry}
\usepackage{changepage}
\usepackage{nopageno}
\setlength{\arrayrulewidth}{.5mm}
\setlength{\tabcolsep}{20pt}
\begin{document}
\begin{adjustwidth}{-1.5cm}{}
\rowcolors{2}{gray!25}{white}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
\multicolumn{8}{|c|}{Maze Score Sheet} \\
\hline
\rowcolor{gray!50}
Trial & Score & Trial & Score & Trial & Score & Trial & Score \\
\hline
\rule{0pt}{20pt} 1 & & 26 & & 51 & & 76 & \\
\rule{0pt}{20pt} 2 & & 27 & & 52 & & 77 & \\
\rule{0pt}{20pt} 3 & & 28 & & 53 & & 78 & \\
\rule{0pt}{20pt} 4 & & 29 & & 54 & & 79 & \\
\rule{0pt}{20pt} 5 & & 30 & & 55 & & 80 & \\
\rule{0pt}{20pt} 6 & & 31 & & 56 & & 81 & \\
\rule{0pt}{20pt} 7 & & 32 & & 57 & & 82 & \\
\rule{0pt}{20pt} 8 & & 33 & & 58 & & 83 & \\
\rule{0pt}{20pt} 9 & & 34 & & 59 & & 84 & \\
\rule{0pt}{20pt} 10 & & 35 & & 60 & & 85 & \\
\rule{0pt}{20pt} 11 & & 36 & & 61 & & 86 & \\
\rule{0pt}{20pt} 12 & & 37 & & 62 & & 87 & \\
\rule{0pt}{20pt} 13 & & 38 & & 63 & & 88 & \\
\rule{0pt}{20pt} 14 & & 39 & & 64 & & 89 & \\
\rule{0pt}{20pt} 15 & & 40 & & 65 & & 90 & \\
\rule{0pt}{20pt} 16 & & 41 & & 66 & & 91 & \\
\rule{0pt}{20pt} 17 & & 42 & & 67 & & 92 & \\
\rule{0pt}{20pt} 18 & & 43 & & 68 & & 93 & \\
\rule{0pt}{20pt} 19 & & 44 & & 69 & & 94 & \\
\rule{0pt}{20pt} 20 & & 45 & & 70 & & 95 & \\
\rule{0pt}{20pt} 21 & & 46 & & 71 & & 96 & \\
\rule{0pt}{20pt} 22 & & 47 & & 72 & & 97 & \\
\rule{0pt}{20pt} 23 & & 48 & & 73 & & 98 & \\
\rule{0pt}{20pt} 24 & & 49 & & 74 & & 99 & \\
\rule{0pt}{20pt} 25 & & 50 & & 75 & & 100 &\\
\hline
\end{tabular}
\end{adjustwidth}
\end{document}
答案1
讓我詳細闡述我的評論。您的表格將移至下一頁,因為它已達到高度。您在第一頁上看到的行(它們也在第二頁上,但由於被表格覆蓋而不太明顯)顯示頁面佈局並由geometry
option生成showframe
,並不是表格不在第一頁上的原因(您期望的位置)。考慮到我在評論中的第二個建議——減少桌子高度——給出:
假設表中的所有列具有相同的寬度,我建議使用tabularx
表格環境。為了在表體中有更多的垂直空間,我寧願使用cellspace
包\rule{0pt}{20pt}
。為了使列標題具有不同的高度,我將它們包含在multicolumn
巨集中。
\documentclass[11pt]{article}
\usepackage[%showframe % show page layout
% handy in phase of table design
% in real document had to be removed
]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage{cellspace, % for defining vertical space above and bottom of cells' content
tabularx} % for `X` column type
\setlength\cellspacetoplimit{7pt} % additional top vertical space
\setlength\cellspacebottomlimit{7pt} % additional bottom vertical space
\newcolumntype{C}{>{\centering\arraybackslash}X} % for center content in X colums
\newcommand\mc[1]{\multicolumn{1}{c|}{#1}} % shorthand for multicolum
\begin{document}
\pagestyle{empty}
\begingroup
\setlength{\arrayrulewidth}{.5pt}
\rowcolors{2}{gray!20}{white}
\centering
\begin{tabularx}{\linewidth}{|*{8}{SC|}}
\hline
\multicolumn{8}{|c|}{Maze Score Sheet} \\
\hline
\rowcolor{gray!40}
\multicolumn{1}{|c|}{Trial} & \mc{Score}
& \mc{Trial} & \mc{Score}
& \mc{Trial} & \mc{Score} & \mc{Trial} & \mc{Score} \\
\hline
1 & & 26 & & 51 & & 76 & \\
2 & & 27 & & 52 & & 77 & \\
3 & & 28 & & 53 & & 78 & \\
4 & & 29 & & 54 & & 79 & \\
5 & & 30 & & 55 & & 80 & \\
6 & & 31 & & 56 & & 81 & \\
7 & & 32 & & 57 & & 82 & \\
8 & & 33 & & 58 & & 83 & \\
9 & & 34 & & 59 & & 84 & \\
10 & & 35 & & 60 & & 85 & \\
11 & & 36 & & 61 & & 86 & \\
12 & & 37 & & 62 & & 87 & \\
13 & & 38 & & 63 & & 88 & \\
14 & & 39 & & 64 & & 89 & \\
15 & & 40 & & 65 & & 90 & \\
16 & & 41 & & 66 & & 91 & \\
17 & & 42 & & 67 & & 92 & \\
18 & & 43 & & 68 & & 93 & \\
19 & & 44 & & 69 & & 94 & \\
20 & & 45 & & 70 & & 95 & \\
21 & & 46 & & 71 & & 96 & \\
22 & & 47 & & 72 & & 97 & \\
23 & & 48 & & 73 & & 98 & \\
24 & & 49 & & 74 & & 99 & \\
25 & & 50 & & 75 & & 100 &\\
\hline
\end{tabularx}
\endgroup
答案2
若要使框架線消失,請不要showframe
在載入geometry
套件時指定該選項。
我認為目標是讓記分錶填滿可用的文字區塊。如果是這種情況,請不要過度使用adjustbox
,也不要\rule{0pt}{20pt}
在每一行中插入排版支柱。設定\tabcolsep
合理\arraystretch
的值會更有效。
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage{geometry}
\pagestyle{empty}
\begin{document}
\begin{table}[p] % place the table on a page by itself
\setlength{\arrayrulewidth}{.5mm} % this is really ugly...
\setlength{\tabcolsep}{14.1pt}
\renewcommand\arraystretch{1.5}
\rowcolors{2}{gray!20}{white}
\noindent % <--- this is important
\begin{tabular}{|*{8}{c|}}
\hline
\multicolumn{8}{|c|}{Maze Score Sheet} \\
\hline
\rowcolor{gray!40}
Trial & Score & Trial & Score & Trial & Score & Trial & Score \\
\hline
1 & & 26 & & 51 & & 76 & \\
2 & & 27 & & 52 & & 77 & \\
3 & & 28 & & 53 & & 78 & \\
4 & & 29 & & 54 & & 79 & \\
5 & & 30 & & 55 & & 80 & \\
6 & & 31 & & 56 & & 81 & \\
7 & & 32 & & 57 & & 82 & \\
8 & & 33 & & 58 & & 83 & \\
9 & & 34 & & 59 & & 84 & \\
10 & & 35 & & 60 & & 85 & \\
11 & & 36 & & 61 & & 86 & \\
12 & & 37 & & 62 & & 87 & \\
13 & & 38 & & 63 & & 88 & \\
14 & & 39 & & 64 & & 89 & \\
15 & & 40 & & 65 & & 90 & \\
16 & & 41 & & 66 & & 91 & \\
17 & & 42 & & 67 & & 92 & \\
18 & & 43 & & 68 & & 93 & \\
19 & & 44 & & 69 & & 94 & \\
20 & & 45 & & 70 & & 95 & \\
21 & & 46 & & 71 & & 96 & \\
22 & & 47 & & 72 & & 97 & \\
23 & & 48 & & 73 & & 98 & \\
24 & & 49 & & 74 & & 99 & \\
25 & & 50 & & 75 & & 100 &\\
\hline
\end{tabular}
\end{table}
\end{document}
答案3
不要手動調整寬度,而是使用\makebox[\linewidth]{<table>}
自動居中表格,並且不要忘記\noindent
。正如其他人所說,使用\renewcommand\arraystretch{<value>}
而不是\rule
在每一行添加一個。最後考慮選擇更合理的值以\arrayrulewidth
獲得\tabcolsep
最大的視覺清晰度。
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[table]{xcolor}
\usepackage{geometry}
\usepackage{changepage}
\usepackage{nopageno}
\begin{document}
\renewcommand\arraystretch{1.5} % <---
\setlength{\arrayrulewidth}{.5mm}
\setlength{\tabcolsep}{20pt}
\noindent\makebox[\linewidth]{% <---
\rowcolors{2}{gray!25}{white}
\begin{tabular}{|*8{c|}}
\hline
\multicolumn{8}{|c|}{Maze Score Sheet} \\
\hline
\rowcolor{gray!50}
Trial & Score & Trial & Score & Trial & Score & Trial & Score \\
\hline
1 & & 26 & & 51 & & 76 & \\
2 & & 27 & & 52 & & 77 & \\
3 & & 28 & & 53 & & 78 & \\
4 & & 29 & & 54 & & 79 & \\
5 & & 30 & & 55 & & 80 & \\
6 & & 31 & & 56 & & 81 & \\
7 & & 32 & & 57 & & 82 & \\
8 & & 33 & & 58 & & 83 & \\
9 & & 34 & & 59 & & 84 & \\
10 & & 35 & & 60 & & 85 & \\
11 & & 36 & & 61 & & 86 & \\
12 & & 37 & & 62 & & 87 & \\
13 & & 38 & & 63 & & 88 & \\
14 & & 39 & & 64 & & 89 & \\
15 & & 40 & & 65 & & 90 & \\
16 & & 41 & & 66 & & 91 & \\
17 & & 42 & & 67 & & 92 & \\
18 & & 43 & & 68 & & 93 & \\
19 & & 44 & & 69 & & 94 & \\
20 & & 45 & & 70 & & 95 & \\
21 & & 46 & & 71 & & 96 & \\
22 & & 47 & & 72 & & 97 & \\
23 & & 48 & & 73 & & 98 & \\
24 & & 49 & & 74 & & 99 & \\
25 & & 50 & & 75 & & 100 &\\
\hline
\end{tabular}
}
\end{document}