I've been working with a large document in Sharelatex for some time and I kept getting a fontspec error that it could not find the font file. However, despite this error message the document kept compiling normally, that is until I switched the font to Garamond. Now the document will only compile the sans-serif portion of the document.

Below is my MWE without the sans serif portion.

\usepackage[paperwidth=7.5in, paperheight=9.25in, top=1in,   bottom=1.375in, left=1in, right=1in]{geometry}

 %This is ShareLaTeX Specific (or if the fonts are not installed in your system)
% Garamond

Something is wrong! I am momentarily blinded and confused by moving, overlapping, translucent images that overwhelm my vision of the book I am reading. The room I sit in is visually a frenetic whirling mess. Abject fear grips me, first at the base of my spine, then it rips up my spine to my cortex and beyond. \par


Any ideas of how to fix this? I've tried altering the file names, but this has produced no result.

  • Normally, you have to indicate only the name of the font family (not the name of the .otf file. Did you check the family name, as it is known by your system?
    – Bernard
    Jul 19, 2016 at 17:20
  • 1
    The problem here is that, by using ShareLatex, I have to upload the files off the system and then provide the file name. That's why I included the .otf, since it doesn't seem to work without it.
    – Richard
    Jul 19, 2016 at 17:46
  • They have an example of this here: sharelatex.com/project/578e6a78e0a7f0c46bcd6add
    – Richard
    Jul 19, 2016 at 18:00
  • Fixed it, for some reason it demands that I change the font name that SharLatex gives it to the one that matches the computer's name for it.
    – Richard
    Jul 19, 2016 at 18:37
  • for me the reason was because of read permission, fixed with chmod +rw Dec 13, 2020 at 10:13

2 Answers 2


With setmainfont you're essential building case-sensitive font paths.

  • Path=working directory for fonts
  • BoldFont=filename segment of path
  • ItalicFont=filename segment of path
  • Extension=file extension of path

You're code does not work because you are telling fontspec to look in all paths like this (example shows paths for bold font):

... any other font directory in your environment/GARABD.otf/GARAMOND.otf

TeX Default Known Font Path Segments

On Unix-based computers, you can figure out the TeX font folders with:

cat $(kpsewhich -var-value TEXMFSYSVAR)/fonts/conf/texlive-fontconfig.conf

which evaluates to /home/texlive/2016/texmf-var/fonts/conf for 2016, or for the appropriate year of your installed version.

Otherwise fontspec does have an automatic path finding mechanism for system fonts, where you can just do \setmainfont{Arial}, but this is not as explicit and therefore in my experience leads to problems with cross-platform or cross-computer compatibility.

See How do I load a texlive font with fontspec?

Empowering YOU to DO it Yourself

Find folder where you files reside (without knowing your OS, I will just make up something)

Given fonts are in same folder with these names:


How would I set up fontspec for this?

  Path = /Library/Fonts/ ,
  UprightFont = MOND ,
  BoldFont = BD ,
  ItalicFont = IT ,
  Extension = .otf
]{GARA} % {contains only what is common among all file names (usually basename of font family)} 


Many pro fonts use dashes in their file names to separate the variants, so you'll often see the following:


How would i set this up? Well, unfortunately fontspec does not support all of those fonts simultaneously, so I might either settle for less and use \setmainfont or load them all by breaking them up into families e.g. \newfontfamily\dejavucondensed \newfontfamily\dejavu \newfontfamily\dejavulight.

  Path = /Library/Fonts/ ,
  UprightFont = ,
  BoldFont = -Bold ,
  ItalicFont = -Oblique ,
  Extension = .ttf
]{DejaVuSans} % {contains only what is common among all file names (usually basename of font family)} 

The \set*font commands should accept a parameter Path=[Path] that points to the directory containing the files. This is only relevant if using fonts that are not known to the system. Otherwise you should provide the name of the font family as noted by bernard (first comment).

You must log in to answer this question.

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