On 03/10/2010 4:57 AM, Steve Litt wrote:
U D Man Julien!!!
Well, to be fair the main hint of using afterpage came from Paul.
\gdef didn't work, but \xdef sure did. I replaced this:
\afterpage{\renewcommand{\plotdatehdr}[0]{\plotdateondeck}}
With this:
\afterpage{\xdef\plotdatehdr{\plotdateondeck}}
And bang! It does what it's supposed to. I set \plotdatehdr with the chapter
date charstyle, and that determines the header date of the first page of the
chapter. After that, the header date is the last value input with the body
date charstyle before the current page. That's exactly what I wanted.
\gdef worked for me, but I also had just one variable \currentdate which
you either set directly by \def\currentdate{Oct. 3} or set indirectly,
after the page, with \setdate{Oct. 4}.
I'm still not quite sure it works right so I won't yet put<SOLVED> in the
subject. I need to investigate this more thoroughly tomorrow. I also need to
find out exactly what \xdef does that \gdef and \def and \renewcommand don't
do, but there's time for that tomorrow.
\gdef and \xdef are global, the others \def and \newcommand family are
constrained to the current scope {}.
The difference between \gdef and \xdef is that \xdef will extend any
macro at the time of definition, and \gdef does not. So in your case:
\xdef\plotdatehdr{\plotdateondeck}
\plotdateondeck is expanded to its content ("Oct. 3", or whatever it is
at the time of definition) before assignment of the def, so \plotdatehdr
is defined to "Oct. 3".
If you use \gdef then \plotdatehdr would be defined to \plotdateondeck
like a regular \def would do; that macro is expanded only at execution
time, at which point its content might have already changed.
You are probably good with using \xdef in your case. oh, the subtleties
of TeX!
Julien