![长表的水平线未跨越某些列](https://linux22.com/image/397377/%E9%95%BF%E8%A1%A8%E7%9A%84%E6%B0%B4%E5%B9%B3%E7%BA%BF%E6%9C%AA%E8%B7%A8%E8%B6%8A%E6%9F%90%E4%BA%9B%E5%88%97.png)
我正在创建一个表格来记录与活动主办相关的赞助商名单。
\documentclass[12pt, a4paper]{article}
\usepackage[margin=2.5cm, left=2.4cm, right=1.7cm]{geometry}
\usepackage{graphicx}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{cellspace,multirow}
\usepackage{caption}
\usepackage{tabularx,ragged2e}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\setlength\cellspacetoplimit{1.75pt} % <----
\setlength\cellspacebottomlimit{1.75pt} % <----
\usepackage[table,xcdraw]{xcolor}
\renewcommand{\baselinestretch}{1}
\begin{document}
\afterpage{
\begin{landscape}
\section{Sponsorship List}
\begin{table}[!ht]
\normalsize % <----
\begin{tabularx}{\textwidth}{|C{0.7cm}|C{2cm}|C{4cm}|C{3.5cm}|C{2.5cm}|C{2.5cm}|C{3cm}|C{3cm}|C{3cm}|C{3cm}|C{3cm}|C{3cm}}
\hline
\multirow{2}{*}{No.} & \multirow{2}{*}{Date} & \multirow{2}{*}{Company} & \multirow{2}{*}{Manager} & \multicolumn{2}{c|}{Amount Secured} & \multirow{2}{*}{Phone Number} & \multicolumn{2}{c|}{Person-in-charge} & \multirow{2}{*}{Status} \\ \cline{5-6} \cline{8-9}
& & & & Cash (RM) & Goods & & Name & Student ID & \\ \hline
1 & 13.05.2019 & XXXX XXX XXXXXXXX Sdn. Bhd. & & 0 & - & & XX XXX XXX & XXX0000000 & Rejected \\ \hline
2 & 17.05.2019 & XXX TUITION CENTER & & 0 & - & & XX XXX XXX & XXX0000000 & Rejected \\ \hline
3 & 17.05.2019 & XXX ESPORT & & 0 & - & & XX XXX XXX & XXX0000000 & Rejected \\ \hline
4 & 20.05.2019 & XXXXX Park & & 0 & - & & XX XXX XXX& XXX0000000 & Rejected \\ \hline
5 & 21.05.2019 & XXXX TUITION CENTER & & 0 & - & & XX XXX XXX & XXX0000000 & Rejected\\ \hline
6 & 23.05.2019 & XdXmy & & 0 & - & & XX XXX XXX & XXX0000000 & Rejected \\ \hline
7 & 25.05.2019 & X\&X & & 0 & - & & XX XXX XXX & XXX0000000 & Rejected\\ \hline
8 & 27.05.2019 & XX XXXXXX ELECTRICAL Sdn. Bhd. & & 200 & - & & XX XXX XXX & XXX0000000 & Confirmed\\ \hline
9 & 27.05.2019 & XXXXXX NYONYA & & 0 & - & & XX XXX XXX & XXX0000000 & Rejected\\ \hline
10 & 28.05.2019 & XXXX MARKETING Sdn. Bhd. & & 0 & - & & XX XXX XXX & XXX0000000 & Rejected\\ \hline
11 & 30.05.2019 & XXXXXXX Coldstorage XXXXXXX Sdn. Bhd. & & - & - & & XX XXX XXX & XXX0000000 & No Response \\ \hline
12 & 06.06.2019 & XXXXXXXXX & & 0 & - & & XX XXX XXX & XXX0000000 & No Response\\ \hline
13 & 13.06.2019 & - & WXXX TXXX TXXX & - & Dinner & +6 XXX XXX XXX & XX XXX XXX & XXX0000000 & Confirmed\\ \hline
\end{tabularx}
\caption{Time Frame for Event}
\end{table}
\end{landscape}}
\end{document}
由于表格太长,列太多,所以编译器编译出来的PDF如下:
缺少最后一列,并且水平线未到达第 6 至第 10 列。我该如何调整它以使表格位于一页中?
答案1
使用较小的字体大小、缩小的字体\tabcolsep
以及正确使用包X
中的类型列tabularx
,您可以轻松地将表格放入页边距中。为了使表格变窄,我还引入了“状态”列的符号。如果您的表格包含更多条目,则可能不适合页面。在这种情况下,您可能需要使用该xltabular
包允许在表格内进行分页。如果您对自动处理第一列中的数字感兴趣(如果您必须在中间添加一行,则特别有用),您可能需要查看:https://tex.stackexchange.com/a/21245/134144
\documentclass[12pt, a4paper]{article}
\usepackage[margin=2.5cm, left=2.4cm, right=1.7cm]{geometry}
\usepackage{graphicx}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{cellspace,multirow}
\usepackage{caption}
\usepackage{tabularx,ragged2e}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\setlength\cellspacetoplimit{1.75pt} % <----
\setlength\cellspacebottomlimit{1.75pt} % <----
\newcolumntype{Y}{>{\centering}X}
\usepackage[table,xcdraw,dvipsnames]{xcolor}
\renewcommand{\baselinestretch}{1}
\usepackage{pifont}
\usepackage[outline]{contour}
\contourlength{0.5pt}
\contournumber{10}
\newcommand{\cmark}{\textcolor{Green}{\ding{51}}}
\newcommand{\xmark}{\textcolor{red}{\ding{55}}}
\newcommand{\nmark}{\textcolor{BurntOrange}{\contour{BurntOrange}{--}}}
\begin{document}
\afterpage{
\begin{landscape}
\section{Sponsorship List}
\begin{table}[!ht]
\footnotesize \setlength{\tabcolsep}{3pt}
\begin{tabularx}{\linewidth}{|c|c|Y|Y|c|c|c|Y|c|c|}
\hline
\multirow{2}{*}{No.} & \multirow{2}{*}{Date} & \multirow{2}{*}{Company} & \multirow{2}{*}{Manager} & \multicolumn{2}{c|}{Amount Secured} & \multirow{2}{*}{Phone Number} & \multicolumn{2}{c|}{Person-in-charge} & \multirow{2}{*}{Status} \\ \cline{5-6} \cline{8-9}
& & & & Cash (RM) & Goods & & Name & Student ID & \\ \hline
1 & 13.05.2019 & XXXX XXX XXXXXXXX Sdn. Bhd. & & 0 & - & & XX XXX XXX & XXX0000000 & \xmark \\ \hline
2 & 17.05.2019 & XXX TUITION CENTER & & 0 & - & & XX XXX XXX & XXX0000000 & \xmark \\ \hline
3 & 17.05.2019 & XXX ESPORT & & 0 & - & & XX XXX XXX & XXX0000000 & \xmark \\ \hline
4 & 20.05.2019 & XXXXX Park & & 0 & - & & XX XXX XXX& XXX0000000 & \xmark \\ \hline
5 & 21.05.2019 & XXXX TUITION CENTER & & 0 & - & & XX XXX XXX & XXX0000000 & \xmark \\ \hline
6 & 23.05.2019 & XdXmy & & 0 & - & & XX XXX XXX & XXX0000000 & \xmark \\ \hline
7 & 25.05.2019 & X\&X & & 0 & - & & XX XXX XXX & XXX0000000 & \xmark \\ \hline
8 & 27.05.2019 & XX XXXXXX ELECTRICAL Sdn. Bhd. & & 200 & - & & XX XXX XXX & XXX0000000 & \cmark \\ \hline
9 & 27.05.2019 & XXXXXX NYONYA & & 0 & - & & XX XXX XXX & XXX0000000 & \xmark \\ \hline
10 & 28.05.2019 & XXXX MARKETING Sdn. Bhd. & & 0 & - & & XX XXX XXX & XXX0000000 & \xmark \\ \hline
11 & 30.05.2019 & XXXXXXX Coldstorage XXXXXXX Sdn. Bhd. & & - & - & & XX XXX XXX & XXX0000000 & \nmark \\ \hline
12 & 06.06.2019 & XXXXXXXXX & & 0 & - & & XX XXX XXX & XXX0000000 & \nmark \\ \hline
13 & 13.06.2019 & - & WXXX TXXX TXXX & - & Dinner & +6 XXX XXX XXX & XX XXX XXX & XXX0000000 & \cmark \\ \hline
\multicolumn{10}{p{0.99\linewidth}}{\xmark~= Rejected, \nmark~= No Response, \cmark~= Confirmed}
\end{tabularx}
\caption{Time Frame for Event}
\end{table}
\end{landscape}}
\end{document}