TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am modifying an existing C program which trawls through a database and creates a Latex document from the guff it finds. The majority of the data needs to be plopped into tables, so it uses the longtable environment to allow for page-spanning tables.

There are now instances where the data to be added to a cell is sooo large that latex pushes the cell off the bottom of the page, then recognises it can't fit the table on the page and tries on another page. This goes on and on, finishing up with .dvi and .log files which fill the swap space on the production server. This is not good, and I am getting a bit of flak to be honest!

Obviously, the documents are created "on-the-fly" so, without a lot of fiddly stuff, it's not a simple thing of "Oh, here's where the text runs off the page. I need to add a pagebreak there, then".

I understand there might be a way that the fontsize for data in a cell is scaled according to the content therein...? Is this part of longtable or is it something else lower-down in the bowels of the Latex machinery?

share|improve this question
If a table cell is taller than one page it seems like a table may not be the best way to organize this information. – Matthew Leingang Oct 11 '11 at 11:54
We'd need some more information on the data you have to organize, for instance a sample of these tables. – egreg Oct 11 '11 at 12:00
Welcome to TeX.sx! You don't have to sign with your name since it automatically appears in the lower right corner of your post. – Martin Scharrer Oct 11 '11 at 12:07
up vote 1 down vote accepted

Since you are using a C program to build the LaTex, what if you added code to check the length of a string in any one cell and if it pops a limit, close the cell and start a new line skipping over to the appropriate cell under the one above. In this manner, you maintain your cell alignment, but give longtable a chance to breath. If you have multiple cells that might be extra long within the same row, your logic might have to watch multiple cells at the same time.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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