On 08/14/2013 10:16 PM, Steve Litt of Troubleshooters.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
========================================
Ideally, what I'd like to do is set (or not set) command \stevelitt in
the LyX Document Preamble, but that doesn't work --- define it or not,
the layout code acts as if it's not defined. I suspect the reason is
that LyX places the code from the layout file earlier in the resultant
LaTeX file than the LyX document preamble, so \stevelitt is always
undefined *when the conditionally compiled code is encountered*.
Yes, that is correct.
Try wrapping the conditional code in \AtBeginDocument to defer its
execution.
My ideal solution to this conditional compilation would be to simply
define a variable within the LyX file and have that work. I haven't
been able to do that. Uglier solutions, which I haven't tried yet,
would be to modify the layout with AWK just before the compilation, or
run the LaTeX command like:
latex "\edef\stevelitt{$1}\input{myfile.latex}"
Something I *haven't* been able to get to work is to put the
conditional code inside a command and just call the command from the
LyX LaTeX preamble. The conditional code gets arguments like #1 very
confused when it's placed inside a command.
I think in that case you may have to use ##1 or something, but I'd have
to see the actual command.
Richard