Skip to content
  • Using your favourite fonts with ShareLaTeX

    Posted by James on April 2, 2013

    This article was originally published on the ShareLaTeX blog and is reproduced here for archival purposes.

    Until recently LaTeX has used its own font format which has meant that the choice of fonts was limited to those that had been ported or created for use with LaTeX. However, the newer XeLaTeX compiler has built in support for many more font formats, and can use the fonts that come installed with your computer, like Geogria, Times New Roman and Helvetica. ShareLaTeX supports XeLaTeX which means that you are now spoiled for choice when picking your font!

    Using a custom font

    Let's see an example in action. The 'Times New Roman' font is a classic, but not one that we can distribute due to it's license. However, this is probably present on your system, and you can upload the font file to ShareLaTeX. You're looking for a file called something like 'Times New Roman.ttf' or 'Times New Roman.otf'. Depending on your operating system you'll find this in the following directory:

    • Mac OS X: /Library/Fonts
    • Windows: Windows/Fonts
    • Linux: /usr/share/fonts/

    Upload your font file to a ShareLaTeX project:

    Uploading a font to ShareLaTeX We need to make sure that we're using the XeLaTeX compiler, so set this in your project settings:

    Setting the compiler to XeLaTeX Now to include the font in your document, you must the fontspec package:

    \documentclass[11pt]{article}
    \usepackage{fontspec}
    \setmainfont[Ligatures=TeX]{Times New Roman.ttf}
    \begin{document}
    The quick brown fox jumps over the lazy dog
    \end{document}
    

    When you compile your document, you should see the text in the Times New Roman font.

    Where to find fonts

    There are many freely available TrueType (.ttf) and OpenType (.otf) fonts that you can use with ShareLaTeX. The Google WebFonts collection contains many free to use fonts.

    Advanced Examples

    A popular open font is Linux Libertine, and you can find an example of this being used with Ove5rleaf here. The example also show how XeLaTeX has built in support for accented characters, and how to use italic and bold fonts. Update 25/02/2019: archival link, project is no longer available.

    I hope that you will go forth and explore the delightful world of fonts that are available to use with ShareLaTeX.

Sign up for a free account and receive regular updates

등록

Popular Tags


Start writing now!

Create A New Paper

Overleaf is 무료

New to LaTeX?
Start with a template

Company