Sanders, Maarten (M.J.L.) wrote:
Helge,
Basically I want to make an option for conditional text. I took Herbert
Voss suggestions
(www.mail-archive.com/[email protected]/msg12544.html
In my layout Preamble I added:
\newcommand{\Option}[1]{\setboolean{myOption}{#1}}
In the document Preamble I have
\newcommand{\unitwithoptionA}{true}
this is to let the users specify which conditional text is to be
included.
So in the document I have:
ERT \Option{\unitwithoptionA}
And then the two environments with conditional text.
What I would like: users can click an environment and only have to type
the boolean's name. instead of ERT.
You can get some of this with layouts, but I think the layouts
only will support a fixed set of options. So you can have
paragraph types called optionAtrue, optionAfalse, optionBtrue,
optionBfalse, and so on for as many environments as you
care to define. Wether optionA, optionB and so on actually
should be true can then be set up in the document preamble,
and optionAtrue text will be output if optionA is set, otherwise
optionBfalse text will be output instead. What you want?
PS An even better option for me would be to define a begin_true,
end_true, begin_false, end_false environment so that conditional text
would also work over itemized lists, sections etc.
Custom layouts lets you do that, because paragraph styles nest!
So you can have an itemize inside "optionAtrue" if you like.
Or you can have "optionAtrue" and optionAfalse" texts nested
inside an itemize, so the items output depends on optionA.
But if this is all you need - don't bother. It is implemented in the
upcoming lyx 1.4.0! If you think you're capable of
writing a new layout, then you're probably capable of
compiling lyx-1.4.0 from source. You may then
have a look at a document feature called "Branches".
Basically, text in a "branch" is output only if that branch is active.
One use of this is to make an exam with answers included. Turn
the answer branch off, and you can print the questions only.
You seem to want some text in the "true" case and some other text
in the "false" cases, this is achieved with two branches. One
called "Afalse" and another "Atrue". Then you set one and reset the
other to get what you want. And you can make as many branches
as you like, so you can have Bfalse, Btrue, Cfalse, Ctrue and so on.
Latex is not involved in making the branches, lyx output latex
code only for active branches.
Helge Hafting