Why on earth does the following expression give me 0.0pt?
\edef\x{\the\dimexpr 3ex-1ex\relax}
I assume ex is a LaTeX unit, as it isn't in the TeXbook. Please where is it defined in the kernel?
EDIT
Many thanks for the answers. Ah, Joseph Wright had told me about \nullfont in my early days with TeX.
I was trying to complete the list {A_1ex,A_3ex,A_...,A_10ex} by using a scheme that is different from (and may be faster than) that used by \foreach. \foreach can't complete this list or {A_1pt,A_3pt,A_...,A_10pt}. The following usually fails:
\newcount\cnta
\cnta\z@
\foreach \p in {A_1pt,A_3pt,A_...,A_10pt}{%
\global\advance\cnta\@ne
\typeout{Doing \romannumeral\cnta=\p}%
}
I made the test in the package and hence \nullfont was in effect. I will remove font-dependent units from the permissible units, or make their use conditional on being in document body.
I said "may be faster" above because I have found that \foreach looks for ellipsis (...) in every element of the list, via:
\def\pgffor@scanned{%
\ifx\pgffor@value\pgffor@stop
\let\pgffor@next=\pgffor@after
\else
\expandafter\pgffor@dots@in@
\pgffor@value\pgffor@dots@...\pgffor@dots@@\pgffor@stop
\ifpgffor@dots@in@
\let\pgffor@next=\pgffor@handledots
\else
\let\pgffor@next=\pgffor@handlevalue
\fi
<more>
}
EDIT
In the following definition in \foreach, two \relax are missing. Or is it deliberate? I don't think so.
\def\pgffor@makealphabetic#1{%
\pgfutil@tempcnta=#1\relax%
\ifnum\pgfutil@tempcnta>95\relax%
\advance\pgfutil@tempcnta by-96%
\expandafter\def\expandafter#1\expandafter%
{\pgffor@alpha\pgfutil@tempcnta}%
\else%
\advance\pgfutil@tempcnta by-64%
\expandafter\def\expandafter#1\expandafter%
{\pgffor@Alpha\pgfutil@tempcnta}%
\fi%
}
EDIT (2012/09/08)
In
{A_1ex, A_3ex, A_..., A_10ex}
my scheme recovers and uses ex (the original unit) in the completed/filled list. As percusse has pointed out, PGF's scheme requires
{A_1ex, A_3ex, A_...ex, A_10ex}
My scheme can also parse, e.g.,
{A_1pt-2bp*3+(3cc-2ex)/2, A_1pt-3bp*3+(3cc-2ex)/2, A_..., A_1pt-12bp*3+(3cc-2ex)/2}
but, because parsing this type of expression is expensive and unlikely to be passed by any user, I haven't included it in the relevant macros. I have retained it in the package
as a future tool. What makes, e.g., 1pt-2bp*3+(3cc-2ex)/2 expensive to parse is the need to safely confirm that it is 'dimensionable'. A simple counter or dimension assignment will not always work in this case. I welcome some ideas in this regard.
One point: you can't reconstitute the syntax
1pt-2bp*3+(3cc-2ex)/2
after evaluation. Even PGF's scheme can't conceivably do it, for what are you going to put at the positon of X in
{A_1pt-3bp*3+(3cc-2ex)/2, A_1pt-9bp*3+(3cc-2ex)/2, A_...X, A_1pt-27bp*3+(3cc-2ex)/2}
There is not one unit (like pt or ex) to retain.
Maybe there is a need for something like
{A_1pt-3bp*3+(3cc-2ex)/2, A_1pt-9bp*3+(3cc-2ex)/2,
A_...1pt-?bp*3+(3cc-2ex)/2, A_1pt-27bp*3+(3cc-2ex)/2}
Note ?. But won't that go ridiculously too far? TeX isn't theory.


\documentclass{article} \edef\x{\the\dimexpr 3ex-1ex\relax} \begin{document} \x \end{document}reports8.61108pt. Am I missing something? – Gonzalo Medina Sep 6 '12 at 3:53\fontdimen5and the values of 1ex (x-height). – Gonzalo Medina Sep 6 '12 at 4:00\nullfontactive? – Joseph Wright♦ Sep 6 '12 at 6:11