[XeTeX] forcing counter evaluation

Ulrike Fischer news3 at nililand.de
Thu Oct 8 15:08:16 CEST 2009


Am Thu, 08 Oct 2009 05:53:29 -0700 schrieb Michiel Kamermans:

> I'm running into the problem of a counter not being expanded to its 
> actual value, leading xetex to complain that I'm using something that 
> isn't a number where a number is required.
> 
> In a nutshell, I am writing a new package that's fiddling with xetex' 
> interchartoks, and has the following macro command:
> 
> \usepackage{fontspec}
> \newcommand{\lowestclass}{74}
> \newcommand{\highestclass} {240}
> ...
> \newcommand{\setUTransitionTo}[2]{
>     \newcounter{iclass}
>     \forloop{iclass}{\lowestclass}{\value{iclass} < #1}
>     {
>         \XeTeXinterchartoks #1 \value{iclass}={#2}
>     }
>     \forloop{iclass}{#1+1}{\value{iclass} <= \highestclass}}
>     {
>         \XeTeXinterchartoks #1 \value{iclass}={#2}
>     }
> }
> ...
> \setUTransitionTo{228}{\fontspec{Arial}}
> 
> problematically, the "\value{iclass}" command inside the for loops does 
> not yield the number stored in the counter, but yields the text string 
> "\c at iclass" instead, which is very much not what xetex expects to find 
> in a \XeTeXinterchartoks rule, so it dies.

Yes \value gives the real name of the counter. You can even use to
assign a number to the counter. Only in certain places (e.g. inside
\ifthenelse) \value gives the value of the counter. To get in other
places the value of the counter use \the or \number.

\documentclass{article}
	
\begin{document}
\value{section}=15

\number\value{section}

\the\value{section}

\makeatletter
\the\c at section

\number\c at section
\end{document}



-- 
Ulrike Fischer 



More information about the XeTeX mailing list