> I think this may be quite easy to do already, though it is a bit of a
> hack. LyX 2.0's layouts have an "InPreamble" tag, intended primarily
> for use with document classes that want, say, \title to be in the
> preamble. It should be possible to create a "Preamble" layout, with
> InPreamble true, that will just write its contents to the preamble.
Ok, so according to your suggestion I was able to create the
following "preamble.module" file:
#\DeclareLyXModule{Preamble inset}
#DescriptionBegin
#Adds "Preamble" style, which appends its contents to the preamble.
#DescriptionEnd
Format 30
Style Preamble
LatexType command
InPreamble 1
End
The LatexType is required (according to the documentation). After
adding this module the contents of the "Preamble" environment is indeed
appended to the preamble. Unfortunately it is not copied verbatim, ie.
"example" becomes "\{example}". I'm not much of a layout expert. Please
advise.
Anyway, even if this hack succeeds, the idea is still worth
implementing IMHO, so that it wouldn't be a hack anymore. Or maybe at
least adding the similar module (after polishing and correcting it, so
that it will behave more like ERT) to the standard distribution of LyX.
Thank you in advance,
MichaĆ Skrzypek