I would like to use non-TeX fonts in LyX. To do this, I use the Document->Setting->Use non-TeX fonts setting. This setting causes LyX to insert the \usepackage{fontspec} statement automatically into the preamble. However, I would like to load the fontspec with specific options. I have tried to do \usepackage[LY1,T1]{fontspec} for example. Even with this LyX still does \usepackage{fontspec} and I end up with two statements which both load fontspec in the preamble. I have tried using the command Provides fontspec 1 in the layout file in the hope that LyX would not load fontspec automatically. It still does. What is interesting is that LyX does the automatic package loading on a line that precedes the one on which I ask it to load fontspec with specified options.

Does somebody have an idea of how I could condition LyX to let me load fontspec with the required options without it loading fontspec automatically?

• fontspec is a xelatex and lualatex specific package that does not work with latex or pdflatex and does not take options such as LY1 or T1 are you thinking of fontenc (which does take those options) ? – David Carlisle Sep 8 '14 at 20:00
• Thanks David for pointing out my confusion between fonspec and fontenc. I pledge my ignorance: I started using the two packages last week. I have mixed them up. How embarassing? But how could one manage to tell LyX not load a package if one wants to load that package with a specific set of options? Thanks, in advance. – user24098 Sep 8 '14 at 20:09
• David's comment notwithstanding, the way to do this (with options corresponding to the package, of course) is with \PassOptionsToPackage{<options>}{<package>} before the package is loaded. This may be possible in LyX using "ERT"; just a matter of making sure this code comes before LyX loads the package in question. – Paul Gessler Sep 8 '14 at 20:09
• Thank you very much for your response Paul. Your suggestion is certainly a good avenue for me to explore and I think it should work. However, I have one problem, by the time we use "ERT" are we not past the \begin{document} line already (and not in the preamble)? – user24098 Sep 8 '14 at 20:16
• @user24098 sorry I have never seen lyx – David Carlisle Sep 8 '14 at 20:24

For the specific case of fontenc, go to Document --> Settings --> Fonts, set LaTeX font encoding to Custom, and type whichever font encoding you wish in the input field.