表格转到另一页。它有一些残留的线条

表格转到另一页。它有一些残留的线条

这是代码。如您所见,这个表有几个问题。我真的不知道如何让这些线消失并将整个表带到第一页。谢谢! 在此处输入图片描述

\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选项生成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}

在此处输入图片描述

相关内容