subfiles package as workaround
A simpler workaround would be using the
\subfile command of the
subfiles package, which automatically strips the document skeleton.
It's meant for making child documents compilable on their own, but by extension also fits this usecase.
Using a parent/child pair for export without preamble.
It does not help, if the purpose is to export to latex for inclusion in a journal template, where loading extra packages isn't allowed. In this case a viable workaround is to create a file
main.lyx with child document
child.lyx, and export from
main.lyx recursively, which produces a preamble-free
Automation as a script
This could also be easily automated as a script, by exploiting the straight-forward file-format of
- Create a
.tmp.lyx with the same
\begin_header ... \end_header as
child.lyx to ensure consistent export of styles and insets.
- Make its
\begin_body ... \end_body contain only the child-document link.
.tmp.tex. This will create the desired
- Remove the unnecessary