On Friday 01 October 2010 15:46:12 Steve Litt wrote:
> Hi all,
> 
> My new business novel has a timeline, and I don't want the reader confused
> about what day it is. Part of that is a writing task, but I was thinking of
> having the day and date of the action in the footer.
> 
> I figure I can do this by having a null character style that doesn't print
> anything in the output, but merely sets a variable that can be used in the
> footer, or maybe header.
> 
> Here's my question. If the variable switches mid-page, will the footer
>  print the variable value before the switch, or after the switch? Is it the
>  same both for the footer and for the header?

Normally, a variable in the header or footer of the current page prints the 
bottommost value of that variable on the current page. I believe that's 
confusing to the reader, so I implemented it to print the topmost value, which 
is actually the bottom most value on the preceding page, unless this page is 
the start of a chapter. I did that with one char style to instantiate it at 
chapter's start, and another char style to update it throughout the chapter. 
Here's the code:

==========================================================
Preamble

% ############################################
% ### LATEX CODE FOR PLOT DATES IN HEADER
% ############################################
\newcommand{\plotdatehdr}[0]{init}
\newcommand{\plotdateondeck}[0]{init}

% ### Character style -- plot date in LyX, change var in PDF
% ### Set hdr var directly, used at chapter beginnings
\newcommand{\plotdatechapterL}[1]{\renewcommand\plotdatehdr[0]{#1}}


% ### Character style -- plot date in LyX, change var in PDF
% ### Set ondeck for afterpage copy to hdr var, used within chapters
% ### Notice the afterpage does the after page copy
\newcommand{\plotdatebodyL}[1]{%
  \renewcommand\plotdateondeck[0]{#1}%
  \afterpage{\xdef\plotdatehdr{\plotdateondeck}}%
}
% ############################################
% ### END OF LATEX CODE FOR PLOT DATES IN HEADER
% ############################################

EndPreamble

# %%% Plotdate charstyle for beginning of chapter.
# Directly sets variable for header, should not show up in PDF
# Text should not show up in body of PDF, only in header
CharStyle PlotDateChapter
LatexName       plotdatechapterL
LatexType       Command
Font
        Size Tiny
        Color Blue
Font
End


# %%% Plotdate charstyle for insertion in body of chapter.
# Sets variable that gets fed into var for header
# Text should not show up in body of PDF, only in header
CharStyle PlotDateBody
LatexName       plotdatebodyL
LatexType       Command
Font
        Size Tiny
        Color Red
Font
End

==========================================================

Note that once the preceding code is inserted, you can put \plotdatehdr in a 
header or footer, and it will behave as you wanted.

Note that to get a header or footer to print on the chapter title page with 
the Book document class, you must redefine the plain page style to have 
headers and/or footers.

Thanks go out to Paul Rubin for telling me about \afterpage, Julien Rioux for 
telling me about \xdef, and all the rest of you who helped me figure this out.

Thanks

SteveT

Steve Litt
Recession Relief Package
http://www.recession-relief.US
Twitter: http://www.twitter.com/stevelitt

Reply via email to