On Apr 19, 2008, at 10:17 PM, rgheck wrote:
A. Scottedward Hodel wrote:
On Apr 19, 2008, at 8:33 PM, rgheck wrote:
A. Scottedward Hodel wrote:
I am trying to write a textbook layout file (current version is
attached) that will let me set a "switch" in the preamble of my
LyX file so that I can easily generate both a teacher's version
(with solutions) and a student version (without homework
solutions).
What I've attempted to do is to put the command
\def\notestype{teacher}
in the Document -> Settings -> LaTeX preamble
window of LyX. However, this seems to be loaded after the
layout preamble is set. Is there a way for me to have at least
a part of the layout preamble processed /after/ the Documents ->
Settings preamble? If I can do this, then I will be able to
work within LyX rather than LaTeX, which I would like to do.
At present, no, you can't do that, but I'm not sure why you
really need to do so. Can't you just do something like this:
\ifequal\notestype....
in the environments (or commands) themselves? Then it doesn't
matter what gets loaded first. (If this isn't clear, post your
layout, and we can work on it together. All of us!!)
The other possibility is to use branches, which are designed for
precisely this sort of use.
rh
Thanks. I've tried a number of \ifthenelse environment
definitions in the LaTeX version, including the use of xcomment,
but so far nothing that works "cleanly." My current workaround
(temporary) is to just edit the layout and then reconfigure LyX
when I want to change version. Since I won't be changing edition
that often, that's fine for me, but not really appropriate for
general use. I think I may be able to isolate the "offending"
commands to fall in the LyX preamble by themselves, but I'll work
on that later.
I'd have to think about this for a while, but my idea was to define
a LaTeX command that either (a) just repeated its argument or (b)
basically ate its argument, and then to make the solution
environment wrap the command. But I'm not absolutely sure how to do
that. Basically, I want
\begin{solution}stuff here\end{solution}
to turn into something like:
\solutioncmd{\par\noindent{\bf Solution}stuff here}
and then we have:
\newcommand\solutioncmd{%
\ifthenelse{\equal{\notestype}{teacher}}%
{#1}{}}
So either we get
\par\noindent{\bf Solution}stuff here
or we get nothing. But I'm not sure how to do the environment
definition. Probably we need some "group" business.
Uwe, if you're reading this, do you have an idea? (Uwe is our
resident expert on the user list.)
Richard
I may just be being too picky. I was able to \def a LaTeX command
with \ifthenelse very similar to what you describe: I just wanted to
make in a \newenvironment, and these sort of commands don't seem to
mesh well with that macro. My command was
\newcommand{\questxsol}[2]{
\ifthenelse{\equal{\notestype}{teacher}}{#2}
{ \ifthenelse{\equal{\questxenv}{example}} {#2}{#1} } }
The variable \notestype determines whether this is the student or
teacher version, and the variable \questxenv indicates whether this
solution is in a worked example, a homework problem, or an exam
question. (I've been using a single LaTeX file that is \input
inside a question/example/examQuestion environment so that the
questions are modular and formatted according to how they're used.)
Suppose I use the \solutioncmd or \questxsol in LyX rather than a
\newenvironment. How do I incorporate that command into a LyX
paragraph environment, or is that cleanly possible?
A. Scottedward Hodel [EMAIL PROTECTED]
http://homepage.mac.com/hodelas/tar