I am a LaTeX beginner writing on a report using overleaf. I have a main.tex and a refs.bib. I wanted to change the fonts of the text and sections so I added fontspec and titlesec. At first it worked but now I get the following error:

Fatal fontspec error: "cannot-use-pdftex"
! The fontspec package requires either XeTeX or LuaTeX.
! You must change your typesetting engine to, e.g., "xelatex" or
! "lualatex"instead of plain "latex" or "pdflatex".
! See the fontspec documentation for further information. 
! For immediate help type H <return>.

l.28 \msg_fatal:nn {fontspec} {cannot-use-pdftex}

How do I solve this? I would prefer a solution on overleaf.

  • 3
    Welcome to TeX.SX! As the error message states, you must either use XeTeX (or XeLaTeX) or LuaTeX (or LuaLaTeX). I don't know where to click in overleaf, but I suggest searching for those in the gui. – Skillmon likes topanswers.xyz Nov 11 '17 at 18:23
  • 2
    I don't have an Overleaf account, but if you have one, check out the settings button on the top right and try to see if you can specify the engine there. Related: tex.stackexchange.com/q/291354/35864 – moewe Nov 11 '17 at 19:12

(Disclaimer: I'm a support personnel at Overleaf.)

This means your project uses the fontspec package, which can only be compiled with the XeLaTeX or LuaLaTeX engines, so you'll need to change your Overleaf project's compiler accordingly.

Switching compilers on Overleaf V2

Click on the Overleaf menu icon above the file list panel, and change the "Compiler" setting to "XeLaTeX" or "LuaLaTeX".

Switching compilers on Overleaf V1

Click on the Settings icon (i.e. the gear icon) above the preview panel of your Overleaf editor, and then select either "XeLaTeX" or "LuaLaTeX" from the "LaTeX engine" drop list.

Don't forget to click on "Save project settings" to apply the changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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