I'm using the longtable package (together with xcolor for alternating row colors and booktabs for elegant table headers) to generate a huge table. And by huge, I mean it has more than 900 lines and takes up more than 29 pages. However, I'm getting the following error:

TeX capacity exceeded, sorry [main memory size=3000000].

My code is similar to this one:

% Plus a few other new column types

% Alternating colors starting on 3rd row


col1 & col2 & col3 & col4 & col5 & col6 & col7 & col8 & col9 & col10 & col11 \\

% LOTS of rows here. I mean, maybe a few thousand, taking up 30, 40 or more pages.



How can I avoid exceeding the TeX capacity?

(I've already read this page, but my rows already have blank lines between them, thus that solution does not apply to me.)

2 Answers 2


Use luatex it dynamically allocates memory so you are limited by the physical memory available AFAIK (there is no sample file that I can test to tell if it actually works).

  • 1
    And... how to use LuaTeX? I've never used it, and I have no idea about how it can be used. Sep 24, 2010 at 12:28
  • If you are lucky enough, just running lualatex on your document would be all what you need if you are not interested in any of the extra goodies LuaTeX provides. Sep 24, 2010 at 12:50
  • On my Gentoo system, texlive-luatex is not stable yet, and on my Ubuntu server, there is no lualatex executable. I guess I'll wait some more months/years until giving lualatex another try. Oct 1, 2010 at 20:12
  • Use TeXLive 2010 from TUG, it would take years before it gets into Ubuntu (and will be severely outdated by then). Dunno about Gentoo, by the time I was using it there packaging had became a mess. Oct 1, 2010 at 21:08
  • 2
    About one year later, I tried lualatex. It took about 1.5GB of RAM to compile a huge 827-page longtable, but it worked! (after messing a bit with the preamble because of incompatibilities with lualatex, see also tex.stackexchange.com/questions/28642/… ) Oct 29, 2011 at 4:45

A first possibility is to add the option --extra-mem-top=n to your invocation of pdflatex. Replace n by a number of which you suppose it's big enough.

A more permanent solution is to invoke initexmf --edit-config-file=latex and change the line with main_memory. Afterwards you have to rebuild your format files using initexmf --dump=latex. Perform the same for pdflatex to get all configurations straight.

But these are just workarounds, there could be other problems with your document that lead to exceeded capacity errors. Does your document compile with a subset of the rows? Are you sure all your \newcolumntype's and such are correct?

  • Yeah, it compiles when the number of rows is less than 900. I'm not very sure if my columns are correct, but as I said, they DO work when the number of rows is less than 900. Sep 22, 2010 at 20:51
  • 2
    Unfortunately, --extra-mem-top and --extra-mem-bot are parameters exclusive for MiKTeX, and I'm using texlive. :-( Sep 22, 2010 at 23:21
  • 3
    you can set the extra_mem_top and extra_mem_bot in texmf.cnf. Sep 24, 2010 at 12:53
  • 3
    Your solution is valid, but I'd love to have a solution that would not involve root access, or that at least would not require any extra step configuring the installed packages. Why? Because I don't want things stop working whenever someone updates the system or goes to another machine. Oct 1, 2010 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.