# 8 column table with lstinputlisting in LaTeX

I'd like to create a multicolumn table (up to 8 columns) to insert my code via \lstinputlisting{source.c}. But it seems to me that more then 6 columns aren't possibile even tough space is available. How can I get my 8 columns table?

My minimal example is:

\documentclass{report}
\usepackage[portrait,a0paper,margin=1in]{geometry}
\usepackage{listings}

\usepackage{multicol}
\setlength{\columnwidth}{-25in}
\setlength{\columnsep}{-15in}
\setlength{\columnseprule}{0mm}

\begin{document}

\begin{multicols*}{8}
\lstinputlisting{source.c}
\end{multicols*}

\end{document}


But I get this error message:

! Dimension too large. \set@mult@vsize ...dima \vsize \col@number \vsize \advance \vsize -\@tempdim... l.47 \lstinputlisting

• Welcome to TeX-SX! You may have a look at our starter page for a quick intro if you wish to familiarize yourself with our format. May 8 '13 at 9:26

multicols collects all the columns together in one vertical internal columns so that it can balance the column breaking. 8 times the height of A0 is too big for TeX.

Your example runs if you change a0 to a2 (or smaller) so one possibility is to set the poster for that size and then scale the pdf afterwards.

Alternatively if the multicols is only for listing a different technique could be used. There is typically no vertical flexibility in a listing anyway so you could just break after every n lines without having to collect the whole page first.

The above is an 8 column listing of a 3613 line file of the first 3613 integers one per line, set on a2paper. You just need to scale to a0 while printing (ie double its size)

\RequirePackage{fix-cm}
\documentclass{article}
\usepackage{multicol,listings}

\usepackage[portrait,a2paper,margin=1in]{geometry}
\begin{document}

\fontsize{3.1pt}{3.4pt}\selectfont
\begin{multicols*}{8}
\lstinputlisting{ll.txt}
\end{multicols*}

\end{document}

• Splitting the call into something like \lstinputlistings[lastline=500]{source.c} and \lstinputlistings[firstline=501]{source.c} (at the expense of speed) might work. May 8 '13 at 10:34
• I tried to compile it with lualatex --shell-escape latex.tex in order to avoid tex memory issues, but I cannot get more then 5 columns now on a0paper. I think now it's an issue between the count of columns and the paper size (which it wasn't in the before with a2paper and 9 columns). I have 3613 lines of code which I'd like to print out as poster. May 8 '13 at 12:48
• @TilHund It's not a memory issue it's the size of the datatype 8 * height of a0 is bigger than \maximen so multicolumn can not do any arithmetic on these values. Is there a problem with using a4paper (and a very small font) and then just printing that scaled to A0? May 8 '13 at 13:23
• I'd like to print out all 3613 lines of code as poster. I think it's not possibile to create a couple of a4paper in order to print them all together as a0/a1paper!? May 8 '13 at 13:48
• @TilHund No I mean print it all on a single a4 with small fonts (or a2 if you prefer) any mechanism that can print A4 at all can scale a4 to a0 at the printing stage May 8 '13 at 13:49