TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

All of the documents I create with LyX have


in the preamble, which causes problems when I use certain classes or try to switch from pdfLaTaX to XeTeX (for example).

Is there a way to prevent LyX from inserting this line in my documents?

share|improve this question
LyX loads fontenc, because usually it is a good idea to use it (in combination with a T1 font like lmodern): tex.stackexchange.com/questions/664/… Do you have a special reason why you want to NOT load it? – matth Feb 22 '12 at 9:09

As the OP has already figured out, preventing the loading of any font-encoding package is only possible in the global preferences. Unfortunately, LyX misses a per-document setting for this.

However, if you check the "Use non-Tex fonts" option in the LyX document settings, LyX will load fontspec instead of fontenc. So switching to LuaTeX or XeTeX is easy and can be configured on a per-document base.

enter image description here

share|improve this answer
I figured it out after some experimenting. This will indeed replace fontenc with fontspec if checked, but if unchecked it will follow the app preference for LaTeX output and add fontenc if that's enabled. Both can in fact be disabled together (so, no font-encoding related package gets loaded) if both are unchecked. – raxacoricofallapatorius Feb 21 '12 at 22:18
up vote 5 down vote accepted

The relevant settings are in app preferences under Output > LaTeX. Simply uncheck "Use LaTeX font encoding" and no fontenc line will be added:

LyX UI for disabling inclusion of fontenc

share|improve this answer
Ah, its not a document setting, but a global setting. This seems strange to be, but probably is better than nothing (but don't forget to switch it back on afterwards). Thanks for sharing this! – Daniel Feb 21 '12 at 22:27
There's no need to label a self-answer as "Community Wiki": self-answers are perfectly acceptable. – egreg Feb 21 '12 at 22:32
@egreg: Thanks. Playing it on the safe side. – raxacoricofallapatorius Feb 21 '12 at 22:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.