Insert LaTeX preamble commands to a module in LyX

lyxmodules

I am writing a LyX module that I want to have the following structute:

#\DeclareLyXModule{A module that handles amsthm}
#DescriptionBegin
#Defines theorem environments.
#DescriptionEnd

Format 66

Requires    amsthm

Input thms-envs.inc

and then inside thms-envs.inc I want to insert the following LaTeX code:

\theoremstyle{definition}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}

What is the LyX module syntax to achieve that?

I know I can simply go to the document settings and do that, but I want to do it using a module.

Best Answer

The syntax is to use AddToPreamble and EndPreamble. To insert the code you want, you could do the following:

AddToPreamble
  \theoremstyle{definition}
  \newtheorem{theorem}{Theorem}[chapter]
  \newtheorem{corollary}[theorem]{Corollary}
  \newtheorem{lemma}[theorem]{Lemma}
EndPreamble

For more information, please see Help > Customization.

Related Question