Insert preamble code when one of two styles are in use

Richard Kimberly Heck rikiheck at gmail.com
Wed Aug 23 23:17:39 UTC 2023


On 8/22/23 10:14, ehud.behar at posteo.net wrote:
> <pre>Suppose I create two styles.
>
> When Style 1 is in use, I want the LyX editor to add to the preamble the following code:
>
> \usepackage{x}
> latex code for style 1
>
> When style 2 is in use, I want to add to the preamble the following code:
> \usepackage{x}
> latex code for style 2
>
> What I do now to achieve this is
>
> Style Style1
> LatexType             Environment
> LatexName             style1
> Preamble
> \usepackage{x}
> latex code for style 1
> EndPreamble
> End
>
> and
>
> Style Style2
> LatexType             Environment
> LatexName             style2
> DependsOn           Style1  # <<<
> Preamble
> latex code for style 2
> EndPreamble
> End
>
> but this is somewhat inefficient.

There's not really a better way to do this. You could delete the 
"DependsOn" (unless you need it) and instead add "usepackage" to Style2. 
This may result in multiple loadings, but that's not a problem unless 
you specify different options.

Riki

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-users/attachments/20230823/024fc5cd/attachment.html>


More information about the lyx-users mailing list