This must be another of those expansion related issues as I don't know why the following
\def\MaxValueOfTok{8}%
\newtoks{\SomeTokDefinedViaDef}
\SomeTokDefinedViaDef={\MaxValueOfTok}
\pgfmathsetmacro{\Difference}{10-\the\SomeTokDefinedViaDef}%
fails with
Package PGF Math Error: Unknown operator
8' or8@' (in '10-8').
If possible, would prefer a solution that requires only changing the \pgfmathsetmacro computation, and not require any changes to how the token is defined. Alternatively, adjusting how the \def is set up would work as well.
Un-commenting the last two lines in the MWE will reproduce the problem.
Code:
\documentclass{article}
\usepackage{tikz}% Easy way to get pgfmath
\def\MaxValueOfTok{8}%
\newtoks{\SomeTokDefinedDirectly}
\newtoks{\SomeTokDefinedViaDef}
\SomeTokDefinedDirectly={7}
\SomeTokDefinedViaDef={\MaxValueOfTok}
\begin{document}
\pgfmathsetmacro{\Difference}{10-5}%
Differerence is \Difference (numerical).
\pgfmathsetmacro{\Difference}{10-\MaxValueOfTok}%
Differerence is \Difference (using def).
\pgfmathsetmacro{\Difference}{10-\the\SomeTokDefinedDirectly}%
Differerence is \Difference (using SomeTokDefinedDirectly).
%\pgfmathsetmacro{\Difference}{10-\the\SomeTokDefinedViaDef}%
%Differerence is \Difference (using SomeTokDefinedViaDef).
\end{document}

\usepackage{pgf}is better. – percusse Aug 28 '12 at 08:57