5

How can I make a table with 25 columns and 30 lines in one page or more?

Result is

screenshot

Thank you

2
  • 1
    If it is accepted that the font must be shrunk, you can enclose the tabular in a \scalebox{factor}{\begin{tabular}...\end{tabular} and use whatever factor will make it fit. Mar 30, 2014 at 10:39
  • You can also try with lesser \tabcolsep.
    – user11232
    Mar 30, 2014 at 10:50

2 Answers 2

10

First off, 25 columns is a lot to take in! Do ask yourself if your readers might be (much!) better off if you broke up the table into two or three parts, with 12-13 or 8-9 columns each, respectively.

Assuming the columns are fairly narrow to begin with and the default font size is reasonable (e.g., 10pt), a combination of \small (which reduces the font size by 10%) and a small value of the \tabcolsep parameter (e.g., 2pt; the default value is 6pt) might make the table fit if it's landscape-oriented. For such a table, I would definitely not use any vertical bars; since each vertical bar takes up 0.4pt in space, having 26 of them will take up a non-negligible amount of space.

E.g., a table generated by the following code does fit (though only just!) in a page.

\documentclass{article}
\usepackage[margin=1in,showframe]{geometry}
\usepackage{tabularx,rotating,ragged2e,booktabs}
\newcolumntype{C}{>{\Centering\arraybackslash}X}
\setlength\tabcolsep{2pt} % default value: 6pt
\begin{document}
\begin{sidewaystable}
\small
\begin{tabularx}{\textwidth}{@{} *{25}{C} @{} }
\toprule
A & B & C & D & E & F & G & H & I & J & K & L & M & 
N & O & P & Q & R & S & T & U & V & W & X & Y \\
\midrule
 1000 &  2000 &  3000 &  4000 &  5000 &  6000 &  7000 &  8000 &
 9000 & 10000 & 11000 & 12000 & 13000 & 14000 & 15000 & 16000 &
17000 & 18000 & 19000 & 20000 & 21000 & 22000 & 23000 & 24000 & 25000\\
\bottomrule
\end{tabularx}
\end{sidewaystable}
\end{document}

enter image description here

1
  • 1
    The tenth upvote on this answer earned me badges 333 and 334 on this site. Many thanks to the upvoter -- and to all users who make TeX.SE such a fabulous place!!
    – Mico
    Mar 31, 2014 at 4:34
5

Tables containing many lines can be typeset using the longtable-environmet, provided by the longtable-package. This environment allows page breaks within the table environment and is used much like the tabular-environment. Usually I typeset tables containing many columns using the sidewaystable-environment, provided by the rotate-package. However, if you encounter tables containing many columns and lines, those two environments do not work well together. That is why I would recommend you using the landscape-environment, provided by the pdflscape-package. The landscape-environment will turn the whole page — excluding headers and footers — clockwise by 90°. For details see my example below.

\documentclass{article}
\usepackage{longtable}
\usepackage{pdflscape}

\begin{document}
This text will be displayed in portrait-style page layout.
This text will be displayed in portrait-style page layout.
This text will be displayed in portrait-style page layout.
This text will be displayed in portrait-style page layout.

\begin{landscape}                              % From here on the page will be turned sidewards.
\begin{longtable}{l | l | l | l | l | l }
foo & foo & foo & foo & foo & foo\\
\hline
\endhead               % The lines above will be repeated at top of your table on each new page.
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo\\
foo & foo & foo & foo & foo & foo
\end{longtable}
\end{landscape}
\end{document}

You must log in to answer this question.

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