Note: This seems like it has to be asked somewhere, but my Google-foo is failing me. If someone can point me to it, I can delete this question.
I am trying to save a number to the .aux file, and then import that value and assign it to a counter later. I'm toying with the SageTex code to try and find a way to assign a value to a counter based on a sage variable. However, since sage requires two passes, I am trying to use the zref system to use a temporary value for the counter while writing out the sage variable to the .aux file as a label, then pulling that value in on the second pass.
I am new to the zref system so I may just be missing an obvious command, but I can't seem to find a way to important a value from .aux as an argument in the \setcounter command. Here is a MWE:
\documentclass{article}
\usepackage{zref}
\usepackage{zref-user}
\usepackage{xifthen}
\begin{document}
\makeatother
\zref@newlist{SageStorageList}
\zref@setmainlist{SageStorageList}
\zref@newprop{sageContent}[0]{0}
\zref@addprop{SageStorageList}{sageContent}
\newcommand{\storeSage}[2]{
\zref@wrapper@immediate{
\zref@setcurrent{sageContent}{#2}
\zlabel{#1}
}
}
\newcounter{Temp}
\storeSage{TestMe}{5}
\zref[sageContent]{TestMe}
\expandafter\setcounter\expandafter{Temp}\expandafter{\expandafter\zref[sageContent]{TestMe}}
\ifthenelse{\zref[sageContent]{TestMe} > 0}{Ha}{Oh...}
\end{document}
The \expandafter chain is probably overkill but I wanted to ensure the expansion was happening before counter values. Nonetheless I get a "expecting number" error. I tried other expansion configurations in case counters were special for expansion, no luck. This generated the fewest errors (the only error being the "expecting a number" error if you comment out the ifthenelse command).
\expandafterdoesn't work the way you want. The second\expandafterwill try to expand theTwhich isn't expandable. – TH. Jun 18 '17 at 03:19\bgroupis just another name for{and in any event, both are single tokens.\expandafteralways expands the second token to follow it one time. – TH. Jun 18 '17 at 03:38\zref@extract. https://tex.stackexchange.com/questions/95420/decide-whether-a-label-occurs-in-the-current-chapter/95424 – TH. Jun 18 '17 at 03:52