I am researching possibility of building an automatic brief datasheet template in LaTeX, taking data straight out of a database. The database connection part is possible and can be done with such packages as LaTeXDB for mySQL bases.

There is however a second requirement (by company standards). The brief datasheet has to fit on single page only. To do that I'd like to include priorities of data in my database and contain only most important information that fits the page. I also need to check how much room does a block take up on my page and include it conditionally.

My question is - is there any package to test and return information about space taken up by a block (paragraph, table, picture), that I could than use with a conditional scripts in LaTeX?

If this is not the way to do it, I'd appriciate some advice regarding testing how much space will a compiled block of text take up, if sending LaTeX code to the compiler from a C# application.

  • 1
    Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question.
    – Werner
    Commented May 27, 2013 at 14:01

1 Answer 1


The calc package allows you to measure pieces of text: the width of some text can be found with \widthof{<text>}, and the height can be found with \totalheightof{<text>}. Note that these commands use horizontal mode, so if you want to measure more than one line of text, you'll have to use \totalheightof{\parbox{<text>}}.

You can use the xifthen package to construct conditionals based on how much space is left; the dimension \pagetotal contains the height of material already placed on the page and \pagegoal is the height of the textblock.

You must log in to answer this question.