1

I'm dynamically generating LaTeX source and compiling it. The documents contain only tables and each table cell in each column has the same width. I need to work out how many columns are required and figured the best way to do this would be to work out the total possible characters in a line and divide it by the (known) cell width. What is the best way to go about this?

1 Answers1

1
\numexpr\textwidth/(\dimexpr2cm\relax)\relax

is the textwidth divided by 2cm. Unfortunately etex infix arithmetic rounds up so you may need to adjust by +/- 1 depending on your requirements.

The question about characters per line doesn't in general have a good answer as characters are different widths in most fonts.

David Carlisle
  • 757,742