Skip to content

If you're using pdfLaTeX or LaTeX

If you'd like to use a custom font in your document, you can upload the relevant .tfm, .ttf, .fd or .maps file via the files menu, and then create a custom font as usual within your LaTeX document.

Note that if you have a .map file (e.g. to be used along with the font files, you may need to enable it like this in your preamble:


Here's a quick demo showing how to create and use a custom ttf font.

Sometimes you may have received files for a commercially-licensed font in a .zip, where the files are already placed in multiple folders. Assuming you've uploaded these font files to your project, and they are in the folders texmf/fonts/ (.fd, .sty files); texmf/fonts/type1/ (.pfb files); texmf/fonts/tfm/ (.tfm files) etc in your project, adding a file named latexmkrc (no file extensions) with the following lines will point the compiler at them.

$ENV{'TEXINPUTS'}='texmf//:' . $ENV{'TEXINPUTS'};
$ENV{'T1FONTS'}='texmf/fonts/type1//:' . $ENV{'T1FONTS'};
$ENV{'AFMFONTS'}='texmf/fonts/afm//:' . $ENV{'AFMFONTS'};
$ENV{'TEXFONTMAPS'}='texmf/fonts/map//:' . $ENV{'TEXFONTMAPS'};
$ENV{'TFMFONTS'}='texmf/fonts/tfm//:' . $ENV{'TFMFONTS'};
$ENV{'VFFONTS'}='texmf/fonts/vf//:' . $ENV{'VFFONTS'};
$ENV{'ENCFONTS'}='texmf/fonts/enc//:' . $ENV{'ENCFONTS'};

(If you're wondering which files typically go into which folder, have a look at this article.)

If you're using XeLaTeX or LuaLaTeX

The easiest way to use it is via XeLaTeX/LuaLaTeX and fontspec.

  1. Select XeLaTeX/LuaLaTeX as your project's compiler.
  2. Load the fontspec package (this allows you to use TTF/OTF fonts directly)
  3. In your document preamble, add the line


    Note that you no longer need \usepackage[T1]{fontenc} and \usepackage[utf8]{inputenc} when using XeLaTeX and LuaLaTeX as the engine.

  4. Set the fonts you need
  5. You can now set the fonts to be used in your document, using their names as installed in the operating system. (See this link for a list of fonts already installed on Overleaf.) For example:

    \setsansfont{Trebuchet MS} 

    will use Georgia as the serif/roman font; Trebuchet MS as the sans serif font; and Inconsolata for the typewriter/monospaced fonts.

  6. Using a custom font
    1. Add the .ttf or .otf file to your project, by clicking on “Add files” on the top of your file list, and then selecting “Upload from > computer”. Browse to your .ttf/.otf files and upload them.
    2. Use the following syntax instead for the \setxxxfont commands:


      Extension = .ttf,
      UprightFont = *-Regular,

      You can also declare a new font family to use it in arbitrary situations:

      [Extension = .ttf, UprightFont = *-Regular, ...]
      {\crimson This text uses the CrimsonText font}

      See the fontspec documentation for more options.

Overleaf guides

LaTeX Basics


Figures and tables

References and Citations


Document structure





Field specific

Class files

Advanced TeX/LaTeX