Re: Using tex macros in a multidoc

Richard Kimberly Heck via lyx-users <[email protected]> Sat, 16 May 2026 23:31:03 -0400
Newsgroups gmane.editors.lyx.general
Message-ID <[email protected]>
On 5/16/26 4:09 PM, Ehud via lyx-users wrote:
> I have a multi document LyX project:
> File main.lyx, with ch1.lyx, ch2.lyx as child documents of main.lyx .
>
> I use a couple of `math macro` in all of them to save time in typing.
> How can I define those macros one time (preferably in the main file) and tell LyX that all child documents should be aware of those macros?

Macros defined in the main document will be visible in the children. If 
you open the children directly, however, then the main document may not 
be opened: The children are treated as 'standalone' documents, and the 
macros aren't visible.

To fix this, go to Document> Settings> Document Class, and look in the 
middle. There is a field that says "Select default master document". 
Check the box and choose the master document. Then, whenever you open 
the child, it will be opened as a child of that master, and your macros 
will be visible.

Even better, you can put your favorite macros into a special document: 
MyMacros.lyx. Then include that document as a child of any document in 
which you want to use those macros. If it is a document set, as 
described above, just make it the first child, so the macros will be 
visible in all the children. The only downside to this strategy is that 
you may end up with a lot of macros being declared in the LaTeX file 
that you don't actually use. But that's rarely a problem, and if you 
need to submit the LaTeX file to a journal, say, you can manually remove 
the ones you don't need.

Riki


-- 
lyx-users mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-users