I am not an expert in LaTeX, but I was writing a paper, everything was going fine, until it suddenly crashed giving me the error:

The fontspec package requires either XeTeX or LuaTeX to function.

  • 17
    That means that you have to use xelatex <document> or lualatex <document> instead of pdflatex <document> to compile your document if you want to use the fontspec package. For some background, try tex.stackexchange.com/q/36/86 Oct 4, 2012 at 8:49
  • 3
    This can't have happened suddenly. Either you changed how you compile your document (now using pdflatex instead of xelatex for example) or you added fontspec explicitly or a package that loads fontspec implicitly.
    – cgnieder
    Oct 4, 2012 at 11:07
  • As the error message said, LuaLaTeX or XeLaTeX should be used. Probably it wasn't the case. Since no further information was given, the question will now be closed as too localized.
    – Stefan Kottwitz
    Oct 18, 2012 at 12:20
  • @Stefan I tried compile a document with XeLaTeX and got this warning. Aug 8, 2013 at 20:26
  • 2
    I got this same error and there's no answer. Wonder why this question is closed. Dec 22, 2018 at 13:31

1 Answer 1


Yes, the fontspec package package requires a compatible compiler or engine, like Xe(La)TeX or Lua(La)TeX. These compilers are better-equipped to handle fonts.

How do you use Xe(La)TeX or Lua(La)TeX?

Depending on your compilation protocol (via prompt or command-line, a GUI-like interface or even online), you may have to specify it in the command-line:

xetex <your-tex-file>
xelatex <your-tex-file>
luatex <your-tex-file>
lualatex <your-tex-file>

If you're using some interface like a (La)TeX IDE, then the compiler selection would most likely be somewhere in the interface options. It may even be specified as command-line choice. For example, in TeXnicCenter under Windows, compiler choices can be specified by changing the "Path to the (La)TeX compiler":

enter image description here

Online compilers, like Overleaf, provide similar functionality. You can change the compiler to use a different engine in the project settings. See Changing compiler, where you should select Xe(La)TeX or Lua(La)TeX...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .