On 1/20/2015 8:50 PM, Pablo Rodriguez wrote:
Dear list,
I have a question when dealing with XML.
Is there any way to write a conditional based on the number of characters in a given field?
I mean, the following field:
\xmltext{#1}{h1[@class='subtitle']}
If subtitle > 60 chars, then fontsize = 10pt. If subtitle > 50 chars, then fontsize = 12pt. If subtitle > 40 chars, then fontsize = 14pt. If subtitle > 30 chars, then fontsize = 16pt.
How could I write these conditionals?
let tex do the work .. counting is not accurate for this anyway \starttexdefinition AutoFontSize #1 \begingroup \setbox\scratchbox\hbox{#1} \normalexpanded { \definedfont[Regular*default at \ifdim\wd\scratchbox>30em 10pt\else \ifdim\wd\scratchbox>25em 12pt\else \ifdim\wd\scratchbox>20em 14pt\else \ifdim\wd\scratchbox>15em 16pt\fi\fi\fi\fi ] } #1 \endgroup \stoptexdefinition \starttext \dostepwiserecurse{30}{80}{2}{\AutoFontSize{\dorecurse{#1}{x}}\par} \stoptext - ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------