# LyX: import package before LyX-added LaTeX commands

When adding something to the LyX preamble and converting to TeX, it adds the lines after LyX package imports (`\usepackage{amsmath}` and the like), after LyX specific LaTeX commands (`\pdfpageheight\paperheight`), and after Textclass specific LaTeX commands:

``````\theoremstyle{definition}
\newtheorem{defn}{\protect\definitionname}
``````

I would like to import a package at the same time the "normal" packages are imported (`amsmath`, etc.). I saw this question and the accepted answer seemed relevant, but I can't make it work. When I add:

``````PackageOptions mypackage foo
Requires mypackage
``````

to the Local Layout, it adds the line `\PassOptionsToPackage{foo}{mypackage}` before the `\usepackage` lines, but nothing else.

• I've asked your questions like yours before, so I understand if you cannot, but it would be helpful if you asked what you really want to do and give a minimal example of something where you get an error. – scottkosty Jun 15 '17 at 19:43

``````AddToPreamble
• @Ted I'm guessing a bit here, but to get full control you probably need to make a new layout file. Start with a copy of the one corresponding to the documentclass you use, e.g. `article.layout` (on my system that is found in `/usr/share/lyx/layouts/`, place the modified copy in the user directory) – Torbjørn T. Jun 17 '17 at 7:04