On Wed, 14 Aug 2013 22:16:25 -0400
"Steve Litt of Troubleshooters.Com" <stevel...@careersuccess.com> wrote:

> Hi all,
> 
> My Layout file, derived from the Book doc class, has the following
> code:
> 
> ========================================
> \ifx\stevelitt\undefined \else
> \renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\slshape\chaptername{}
> \thechapter: #1}}{}}
> %\renewcommand{\sectionmark}[1]{\markright{\MakeUppercase{\slshape\thesection 
> :
> #1}}} \renewcommand{\sectionmark}[1]{\markright{Steve Stiffler}}
> 
> \fancyhf{}
> \fancyhf[OLH]{\rightmark}
> \fancyhf[ERH]{\leftmark}
> \fancyhf[ORH,ELH]{\thepage}
> 
> \fi
> ========================================

The ideal solution, and in fact my first attempt, would have been to
package the preceding \renewcommand and \fancyhf commands in their own
subroutine (command), and call that command from LyX's LaTeX preamble.
That makes *perfect* sense but doesn't work, because when you wrap the
\renewcommand commands within another command, the #1's involved change
from a prototype to a literal -- #1 of the enclosing command. That's
why I tried the conditional compile in the first place, but we all know
that didn't work because it comes earlier than LyX can set a var.

So I moved the \renewcommands outside of the subroutine, and assigned
them to otherwise meaningless commands \smark and \cmark, which can then
be assigned to \sectionmark and \chaptermark *inside the enclosing
command*. So the solution looks like this:

==========================================
\newcommand{\cmark}[1]{\markboth{\MakeUppercase{\slshape\chaptername{}\thechapter:
 #1}}{}}
\newcommand{\smark}[1]{\markright{\MakeUppercase{\slshape\thesection : #1}}}

\newcommand{\setheader}[1]{%
  \let\chaptermark\cmark
  \let\sectionmark\smark
  \fancyhf{}
  \fancyhf[OLH]{\rightmark}
  \fancyhf[ERH]{\leftmark}
  \fancyhf[ORH,ELH]{\thepage}
}
==========================================

So it sets \cmark and \smark regardless, but those are *used* only if
the \setheader command is run. Pretty cool, huh?

Thanks,

SteveT

Steve Litt                *  http://www.troubleshooters.com/
Troubleshooting Training  *  Human Performance

Reply via email to