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?
Asked
Active
Viewed 484 times
1 Answers
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
wis wider thanitypically (except for tt monospace fonts) – David Carlisle Jan 21 '14 at 12:12tabularxortabularypackages of David Carlisle (sorry if I am wrong). – Fran Jan 21 '14 at 12:37