On Mon, May 21, 2001 at 04:50:08PM +0200, Herbert Voss wrote:
> Steven van Dijk wrote:
> > I've got a master document which "includes" several other files. In the
> > other files, a number of math-macros are used. I can produce my document by
> > doing "include macros.lyx" in the master document before the other
> > includes. If I try to preview a single chapter however, it complains it
> > doesn't know the macros. I can fix this of course by including macros.lyx
> > in the subdocument, but then I get a multiple inclusion error when I try to
> > see the whole document.
> > 
> > In other words, I need something that checks a boolean which is only set by
> > the master document. If it is set, it does not include macros.lyx,
> > otherwise it does. Can anybody tell me how to do this? Preferably without
> > ERT (by hiding it in a layout)?
> 
> this is latex, therefore ert
> have a look at 
> http://www.educat.hu-berlin.de/~voss/lyx/IfThen/ifthen.html

A much simple solution:
Put the include inset (for macros.lyx) inside \select{} command.
In the preamble of the master document, put
 \newcommand{\select}[1]{}
and in the preamble of the included document, put
 \newcommand{\select}[1]{#1}

Another solution, is to just put 
 \let\newcommand=\providecommand
in the preamble of the master document.
This way, including the macros.lyx file several times will not cause an error
(assuming you only use \newcommand).

Reply via email to