我试图使这个表格适合我的页面,其尺寸为:非标准纸张尺寸:宽度 28 厘米,高度 20 厘米。边距应设置得准确,以便有足够的区域容纳宽度为 27.5 厘米、高度为 18 厘米的文本。
我的代码如下:
\documentclass[a4paper,10pt]{article}
\usepackage[papersize=29cm,total=28.5cm]{geometry}
\usepackage{csvtools}
\usepackage{ifthen}
\usepackage{datatool}
\setlength{\parindent}{0cm}
\begin{document}
\begin{center}
{\Large \normalfont Services from Willesden Junction Underground Station towards Elephant \& Castle Underground Station}
\CSVtolongtable{data.csv}{c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c}{
\hline\hline
\multicolumn{20}{|l|}{Monday--Friday}\\
\hline \hline
\bfseries \begin{tabular}{c}5 to\\6am\end{tabular} &
\bfseries \begin{tabular}{c}6 to\\7am\end{tabular} &
\bfseries \begin{tabular}{c}7 to\\8am\end{tabular} &
\bfseries \begin{tabular}{c}8 to\\9am\end{tabular} &
\bfseries \begin{tabular}{c}9 to\\10am\end{tabular} &
\bfseries \begin{tabular}{c}10 to\\11am\end{tabular} &
\bfseries \begin{tabular}{c}11 to\\Midday\end{tabular} &
\bfseries \begin{tabular}{c}Midday\\to 1pm\end{tabular} &
\bfseries \begin{tabular}{c}1 to\\2pm\end{tabular} &
\bfseries \begin{tabular}{c}2 to\\3pm\end{tabular} &
\bfseries \begin{tabular}{c}3 to\\4pm\end{tabular} &
\bfseries \begin{tabular}{c}4 to\\5pm\end{tabular} &
\bfseries \begin{tabular}{c}5 to\\6pm\end{tabular} &
\bfseries \begin{tabular}{c}6 to\\7pm\end{tabular} &
\bfseries \begin{tabular}{c}7 to\\8pm\end{tabular} &
\bfseries \begin{tabular}{c}8 to\\9pm\end{tabular} &
\bfseries \begin{tabular}{c}9 to\\10pm\end{tabular} &
\bfseries \begin{tabular}{c}11 to\\Midnight\end{tabular} &
\bfseries \begin{tabular}{c}Midnight\\to 1am\end{tabular}
\\ \hline}
{%
\ifthenelse{\equal{\insertbyname{w5}}{}}{\insertbyname{w5}&}{{\bf 05} \insertbyname{w5} &}
\ifthenelse{\equal{\insertbyname{w6}}{}}{\insertbyname{w6}&}{{\bf 06} \insertbyname{w6} &}
\ifthenelse{\equal{\insertbyname{w7}}{}}{\insertbyname{w7}&}{{\bf 07} \insertbyname{w7} &}
\ifthenelse{\equal{\insertbyname{w8}}{}}{\insertbyname{w8}&}{{\bf 08} \insertbyname{w8} &}
\ifthenelse{\equal{\insertbyname{w9}}{}}{\insertbyname{w9}&}{{\bf 09} \insertbyname{w9} &}
\ifthenelse{\equal{\insertbyname{w10}}{}}{\insertbyname{w10}&}{{\bf 10} \insertbyname{w10} &}
\ifthenelse{\equal{\insertbyname{w11}}{}}{\insertbyname{w11}&}{{\bf 11} \insertbyname{w11} &}
\ifthenelse{\equal{\insertbyname{w12}}{}}{\insertbyname{w12}&}{{\bf 12} \insertbyname{w12} &}
\ifthenelse{\equal{\insertbyname{w13}}{}}{\insertbyname{w13}&}{{\bf 13} \insertbyname{w13} &}
\ifthenelse{\equal{\insertbyname{w14}}{}}{\insertbyname{w14}&}{{\bf 14} \insertbyname{w14} &}
\ifthenelse{\equal{\insertbyname{w15}}{}}{\insertbyname{w15}&}{{\bf 15} \insertbyname{w15} &}
\ifthenelse{\equal{\insertbyname{w16}}{}}{\insertbyname{w16}&}{{\bf 16} \insertbyname{w16} &}
\ifthenelse{\equal{\insertbyname{w17}}{}}{\insertbyname{w17}&}{{\bf 17} \insertbyname{w17} &}
\ifthenelse{\equal{\insertbyname{w18}}{}}{\insertbyname{w18}&}{{\bf 18} \insertbyname{w18} &}
\ifthenelse{\equal{\insertbyname{w19}}{}}{\insertbyname{w19}&}{{\bf 19} \insertbyname{w19} &}
\ifthenelse{\equal{\insertbyname{w20}}{}}{\insertbyname{w20}&}{{\bf 20} \insertbyname{w20} &}
\ifthenelse{\equal{\insertbyname{w21}}{}}{\insertbyname{w21}&}{{\bf 21} \insertbyname{w21} &}
\ifthenelse{\equal{\insertbyname{w22}}{}}{\insertbyname{w22}&}{{\bf 22} \insertbyname{w22} &}
\ifthenelse{\equal{\insertbyname{w23}}{}}{\insertbyname{w23}&}{{\bf 23} \insertbyname{w23} &}
\ifthenelse{\equal{\insertbyname{w24}}{}}{\insertbyname{w24}}{{\bf 24} \insertbyname{w24} }
\\
}
{
\ifthenelse{\equal{\insertbyname{w5}}{}}{\insertbyname{w5}&}{{\bf 05} \insertbyname{w5} &}
\ifthenelse{\equal{\insertbyname{w6}}{}}{\insertbyname{w6}&}{{\bf 06} \insertbyname{w6} &}
\ifthenelse{\equal{\insertbyname{w7}}{}}{\insertbyname{w7}&}{{\bf 07} \insertbyname{w7} &}
\ifthenelse{\equal{\insertbyname{w8}}{}}{\insertbyname{w8}&}{{\bf 08} \insertbyname{w8} &}
\ifthenelse{\equal{\insertbyname{w9}}{}}{\insertbyname{w9}&}{{\bf 09} \insertbyname{w9} &}
\ifthenelse{\equal{\insertbyname{w10}}{}}{\insertbyname{w10}&}{{\bf 10} \insertbyname{w10} &}
\ifthenelse{\equal{\insertbyname{w11}}{}}{\insertbyname{w11}&}{{\bf 11} \insertbyname{w11} &}
\ifthenelse{\equal{\insertbyname{w12}}{}}{\insertbyname{w12}&}{{\bf 12} \insertbyname{w12} &}
\ifthenelse{\equal{\insertbyname{w13}}{}}{\insertbyname{w13}&}{{\bf 13} \insertbyname{w13} &}
\ifthenelse{\equal{\insertbyname{w14}}{}}{\insertbyname{w14}&}{{\bf 14} \insertbyname{w14} &}
\ifthenelse{\equal{\insertbyname{w15}}{}}{\insertbyname{w15}&}{{\bf 15} \insertbyname{w15} &}
\ifthenelse{\equal{\insertbyname{w16}}{}}{\insertbyname{w16}&}{{\bf 16} \insertbyname{w16} &}
\ifthenelse{\equal{\insertbyname{w17}}{}}{\insertbyname{w17}&}{{\bf 17} \insertbyname{w17} &}
\ifthenelse{\equal{\insertbyname{w18}}{}}{\insertbyname{w18}&}{{\bf 18} \insertbyname{w18} &}
\ifthenelse{\equal{\insertbyname{w19}}{}}{\insertbyname{w19}&}{{\bf 19} \insertbyname{w19} &}
\ifthenelse{\equal{\insertbyname{w20}}{}}{\insertbyname{w20}&}{{\bf 20} \insertbyname{w20} &}
\ifthenelse{\equal{\insertbyname{w21}}{}}{\insertbyname{w21}&}{{\bf 21} \insertbyname{w21} &}
\ifthenelse{\equal{\insertbyname{w22}}{}}{\insertbyname{w22}&}{{\bf 22} \insertbyname{w22} &}
\ifthenelse{\equal{\insertbyname{w23}}{}}{\insertbyname{w23}&}{{\bf 23} \insertbyname{w23} &}
\ifthenelse{\equal{\insertbyname{w24}}{}}{\insertbyname{w24}}{{\bf 24} \insertbyname{w24} }
\\
}
\end{center}
\end{document}
输出如下:
它应该是这样的:
我该如何调整页面大小以适合表格?这是添加标题的正确方法吗?( Services from Willesden Junction Underground Station towards Elephant \& Castle Underground Station
)
我必须说我正在使用 csvtool 包读取 .csv 文件并基于它创建公交车站的时刻表。
答案1
您可能需要将\tabcolsep
长度设置为较低的值。这样可以减少单元格内容和边框之间的空白,并应能达到所要求的表格大小。