1

I am trying to make this table to fit on my page with those sizes: non-standard paper size: width 28 cm, height 20 cm.Margins be set exactly in order to have the area available for text 27.5 cm wide and 18 cm high.

My code looks like this:

\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}

The output is like this: enter image description here

And it suppose to be like this: enter image description here

How can I resize the page that the table will fit? And also is this the right way to add the heading?(Services from Willesden Junction Underground Station towards Elephant \& Castle Underground Station)

I have to say that I am using csvtool package to read a .csv file to create based on it a timetable for a bus station.

6
  • 2
    You might want to set the \tabcolsep length to a lower value. May 17, 2012 at 10:46
  • @MartinScharrer: Thank you! It worked, but I have one more question: As you can see the reference output(the second image) has the departure hours smaller than heading of the table(eg. 05 25 is smaller than 5 to 6am). How can I do that? And also can you give me a tip regarding the heading, because I think I'm not doing in the right way. Thank you. May 17, 2012 at 11:03
  • 1
    Is simply using \small enough? There is also \scriptsize, \footnotesize and \tiny. Ore make the header larger using \large. May 17, 2012 at 11:05
  • @MartinScharrer Can you convert your comments to an answer?
    – egreg
    Oct 6, 2012 at 21:33

1 Answer 1

1

You might want to set the \tabcolsep length to a lower value. This reduces the white space between the cell content and border and should result in the requested table size.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .