[Tex/LaTex] How to typeset tabularx with 34 columns? (Error message)

tablestabularx

I want/need to typeset a very large table with >30 columns, which I created with Excel2LaTeX.

I don't get it to compile, it only works if I really use 20 columns, however when I insert the 21st one, it fails:

\documentclass[11pt, a3paper, landscape]{scrartcl}
\usepackage{tabularx}
\begin{document}

\begin{tabularx}{\textwidth}{|p{2cm}|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|}
\hline

%with 20 columns it will work:
 1 & 2 & 3 & 4 & 5 & 1 & 2 & 3 & 4 & 5 & 1 & 2 & 3 & 4 & 5 & 1 & 2 & 3 & 4 & 5 \\
%with more than 20 columns, it will fail:
    %1 & 2 & 3 & 4 & 5 & 1 & 2 & 3 & 4 & 5 & 1 & 2 & 3 & 4 & 5 & 1 & 2 & 3 & 4 & 5 & 1 & 2 & 3 & 4 & 5  \\
    \hline
    \end{tabularx}
    \end{document}

I'm sorry, I tried to use a large paper format to make everything visible, but at least when I compile it, the table gets larger than the visible "page" strangely.

The logfile I get contains the following:

 This is pdfTeX, Version 3.1415926-1.40.11 (TeX Live 2010) (format=pdflatex 2011.7.9)  22 SEP 2011 16:45
entering extended mode
 \write18 enabled.
 file:line:error style messages enabled.
 %&-line parsing enabled.
**TabularXManyColumns.tex
(./TabularXManyColumns.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, dumylang, nohyphenation, ge
rman-x-2009-06-19, ngerman-x-2009-06-19, afrikaans, ancientgreek, ibycus, arabi
c, armenian, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danis
h, dutch, ukenglish, usenglishmax, esperanto, estonian, ethiopic, farsi, finnis
h, french, galician, german, ngerman, swissgerman, monogreek, greek, hungarian,
 icelandic, assamese, bengali, gujarati, hindi, kannada, malayalam, marathi, or
iya, panjabi, tamil, telugu, indonesian, interlingua, irish, italian, kurmanji,
 lao, latin, latvian, lithuanian, mongolian, mongolianlmc, bokmal, nynorsk, pol
ish, portuguese, romanian, russian, sanskrit, serbian, slovak, slovenian, spani
sh, swedish, turkish, turkmen, ukrainian, uppersorbian, welsh, loaded.
(/usr/local/texlive/2010/texmf-dist/tex/latex/koma-script/scrartcl.cls
Document Class: scrartcl 2011/04/02 v3.09 KOMA-Script document class (article)
(/usr/local/texlive/2010/texmf-dist/tex/latex/koma-script/scrkbase.sty
Package: scrkbase 2011/04/02 v3.09 KOMA-Script package (KOMA-Script-dependent b
asics and keyval usage)

(/usr/local/texlive/2010/texmf-dist/tex/latex/koma-script/scrbase.sty
Package: scrbase 2011/04/02 v3.09 KOMA-Script package (KOMA-Script-independent 
basics and keyval usage)

(/usr/local/texlive/2010/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 1999/03/16 v1.13 key=value parser (DPC)
\KV@toks@=\toks14
)
(/usr/local/texlive/2010/texmf-dist/tex/latex/koma-script/scrlfile.sty
Package: scrlfile 2011/03/09 v3.09 KOMA-Script package (loading files)

Package scrlfile, 2011/03/09 v3.09 KOMA-Script package (loading files)
                  Copyright (C) Markus Kohm

))) (/usr/local/texlive/2010/texmf-dist/tex/latex/koma-script/tocbasic.sty
Package: tocbasic 2011/03/23 v3.09 KOMA-Script package (handling toc-files)
)
Package tocbasic Info: omitting babel extension for `toc'
(tocbasic)             because of feature `nobabel' available
(tocbasic)             for `toc' on input line 115.
Package tocbasic Info: omitting babel extension for `lof'
(tocbasic)             because of feature `nobabel' available
(tocbasic)             for `lof' on input line 116.
Package tocbasic Info: omitting babel extension for `lot'
(tocbasic)             because of feature `nobabel' available
(tocbasic)             for `lot' on input line 117.
Package scrartcl Info: You've used obsolete option `11pt'.
(scrartcl)             \KOMAExecuteOptions{fontsize=11pt} will be
(scrartcl)             used instead.
(scrartcl)             You may simply replace `11pt'
(scrartcl)             by `fontsize=11pt'.
Class scrartcl Info: File `scrsize11pt.clo' used to setup font sizes on input l
ine 1246.

(/usr/local/texlive/2010/texmf-dist/tex/latex/koma-script/scrsize11pt.clo
File: scrsize11pt.clo 2011/04/02 v3.09 KOMA-Script font size class option (11pt
)
)
(/usr/local/texlive/2010/texmf-dist/tex/latex/koma-script/typearea.sty
Package: typearea 2011/04/02 v3.09 KOMA-Script package (type area)

Package typearea, 2011/04/02 v3.09 KOMA-Script package (type area)
                  Copyright (C) Frank Neukam, 1992-1994
                  Copyright (C) Markus Kohm, 1994-

\ta@bcor=\skip41
\ta@div=\count79
Package typearea Info: You've used standard option `landscape'.
(typearea)             This is correct!
(typearea)             Internally I'm using `paper=landscape'.
(typearea)             If you'd like to set the option with \KOMAoptions,
(typearea)             you'd have to use `paper=landscape' there
(typearea)             instead of `landscape', too.
\ta@hblk=\skip42
\ta@vblk=\skip43
\ta@temp=\skip44

Package typearea Warning: Bad type area settings!
(typearea)                The detected line width is about 117%
(typearea)                larger than the heuristically detected line width.
(typearea)                You should e.g. decrease DIV, increase fontsize
(typearea)                or change papersize.

Package typearea Info: These are the values describing the layout:
(typearea)             DIV  = 10
(typearea)             BCOR = 0.0pt
(typearea)             \paperwidth      = 1195.01587pt
(typearea)              \textwidth      = 836.51111pt
(typearea)              DIV departure   = -117%
(typearea)              \evensidemargin = 106.98239pt
(typearea)              \oddsidemargin  = 106.98239pt
(typearea)             \paperheight     = 845.04694pt
(typearea)              \textheight     = 595.80026pt
(typearea)              \topmargin      = -25.16531pt
(typearea)              \headheight     = 17.0pt
(typearea)              \headsep        = 20.40001pt
(typearea)              \topskip        = 11.0pt
(typearea)              \footskip       = 47.60002pt
(typearea)              \baselineskip   = 13.6pt
(typearea)              on input line 1138.
)
\c@part=\count80
\c@section=\count81
\c@subsection=\count82
\c@subsubsection=\count83
\c@paragraph=\count84
\c@subparagraph=\count85
\abovecaptionskip=\skip45
\belowcaptionskip=\skip46
\c@pti@nb@sid@b@x=\box26
\c@figure=\count86
\c@table=\count87
\bibindent=\dimen102
) (/usr/local/texlive/2010/texmf-dist/tex/latex/tools/tabularx.sty
Package: tabularx 1999/01/07 v2.07 `tabularx' package (DPC)

(/usr/local/texlive/2010/texmf-dist/tex/latex/tools/array.sty
Package: array 2008/09/09 v2.4c Tabular extension package (FMi)
\col@sep=\dimen103
\extrarowheight=\dimen104
\NC@list=\toks15
\extratabsurround=\skip47
\backup@length=\skip48
)
\TX@col@width=\dimen105
\TX@old@table=\dimen106
\TX@old@col=\dimen107
\TX@target=\dimen108
\TX@delta=\dimen109
\TX@cols=\count88
\TX@ftn=\toks16
)
(./TabularXManyColumns.aux)
\openout1 = `TabularXManyColumns.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.

./TabularXManyColumns.tex:13: Dimension too large.
\TX@arith ...\ifdim \TX@old@table =\wd \@tempboxa 
                                                  \TX@col@width \TX@old@col ...
l.13    \end{tabularx}

? x

Here is how much of TeX's memory you used:
 1284 strings out of 493763
 19629 string characters out of 3144955
 99667 words of memory out of 3000000
 4640 multiletter control sequences out of 15000+200000
 6379 words of font info for 23 fonts, out of 3000000 for 9000
 715 hyphenation exceptions out of 8191
 35i,8n,44p,233b,186s stack positions out of 5000i,500n,10000p,200000b,50000s
No pages of output.
PDF statistics:
 0 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)

How can I fix that table and make it compile with all its columns?

Best Answer

Probably you have moved on, but for the record, and in case anyone wants to test this before it makes its way into a distribution, I think a possible fix would involve changing tabularx.sty from line 91 so it looks like

existing code:

\def\TX@arith{%
  \TX@false

new lines to be added:

\@tempdimb\maxdimen
\divide\@tempdimb\TX@cols
\ifdim\TX@col@width>\@tempdimb
\TX@typeout@{Don't exceed \maxdimen}%
\wd\@tempboxa\maxdimen
\fi

If you do this please change the \ProvidesPackage line to say

\ProvidesPackage{tabularx}
          [1999/01/07 v2.07 `tabularx' package (DPC) + maxdimen fix]

This fix is incorporated into the tabularx distributed with the 2014 release of LaTeX.

Related Question