I have a custom font I'd like to load to my document. How can I do this?
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. myfont.map
) to be used along with the font files, you may need to enable it like this in your preamble:
\pdfmapfile{+myfont.map}
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
.
- Select XeLaTeX/LuaLaTeX as your project's compiler.
- Load the
fontspec
package (this allows you to use TTF/OTF fonts directly) - Set the fonts you need
- Using a custom font
- 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.
- Use the following syntax instead for the
\setxxxfont
commands:\setmainfont{[CrimsonText-Regular.ttf]}
or
\setmainfont{CrimsonText}[ Extension = .ttf, UprightFont = *-Regular, ...]
You can also declare a new font family to use it in arbitrary situations:
\newfontfamily{\crimson}{CrimsonText} [Extension = .ttf, UprightFont = *-Regular, ...] {\crimson This text uses the CrimsonText font}
See the
fontspec
documentation for more options.
In your document preamble, add the line
\usepackage{fontspec}
Note that you no longer need \usepackage[T1]{fontenc}
and \usepackage[utf8]{inputenc}
when using XeLaTeX and LuaLaTeX as the engine.
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:
\setmainfont{Georgia}
\setsansfont{Trebuchet MS}
\setmonofont{Inconsolata}
will use Georgia as the serif/roman font; Trebuchet MS as the sans serif font; and Inconsolata for the typewriter/monospaced fonts.
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Using the Overleaf project menu
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Using the History feature
- Debugging Compilation timeout errors
- How-to guides
- Guide to Overleaf’s premium features
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Matrices
- Fractions and Binomials
- Aligning equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
- Using the Symbol Palette in Overleaf
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management with bibtex
- Bibliography management with natbib
- Bibliography management with biblatex
- Bibtex bibliography styles
- Natbib bibliography styles
- Natbib citation styles
- Biblatex bibliography styles
- Biblatex citation styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- Multilingual typesetting on Overleaf using babel and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections, equations and floats
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typesetting exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class