On Saturday 02 October 2010 00:49:20 Steve Litt wrote: > Hi all, > > I'm using a document class derived from the Book class, and that can't > change. > > I created a character style that in LyX shows the text, but in the PDF > doesn't show the text and simply sets a variable, which I then put in the > header. So far so good. > > But there's trouble in paradise. These variables are dates, and I want the > variable value in the header to be the value on entry to the page. Instead, > it's the value on exit from the page. Is there any way to make it the value > on entry to the page? Maybe some sort of LaTeX break logic? > > Thanks > > STeveT
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