Skip to content

Encoding

Overleaf uses the UTF-8 encoding for all text files. UTF-8 is the most widely used character encoding on the web today. You can use it to represent any unicode character, which includes an enormous variety of letters, numbers and symbols, including Greek letters and letters with accents.

UTF-8 supersedes many older encodings, such as latin1, latin9, which are often found in LaTeX files and templates. TeX and LaTeX predate UTF-8 by several decades, so LaTeX support for UTF-8 is somewhat inconsistent and depends on which TeX engine you are using.

Support with LaTeX and pdfLaTeX

If you are using pdfLaTeX (i.e., running LaTeX using the pdfTeX engine), which is the default on Overleaf, you can typeset most accented letters and some symbols directly if you include this \usepackage command in the preamble of your document:

\usepackage[utf8]{inputenc}

This should be the only inputenc line in your preamble, so it should replace any that use other encodings.

However, TeX does not know how to typeset all UTF-8 characters. You may get an error like this, if it does not know how to typeset your character:

Package inputenc Error: Unicode char \u8:��� not set up for use with LaTeX.


A more modern TeX engine, such as XeLaTeX or LuaLaTeX, can support such unicode characters natively.

Support with XeLaTeX or LuaLaTeX

If you are using one of these more modern LaTeX engines, you can use much more of UTF-8 directly. You can choose the engine on Overleaf by clicking on Overleaf menu icon above your project's file list panel.

Invalid/Unsupported Characters

For technical reasons, Overleaf cannot store files that contain NUL characters or files that contain characters from outside of Unicode's Basic Multilingual Plane(BMP). The BMP contains only the first 65,536 unicode code points. Some unicode mathematical symbols and some symbols from eastern languages are outside of the BMP. Non-BMP mathematical symbols sometimes arise when copying from PDFs for web pages.

The best workaround is to replace the non-BMP characters with equivalent LaTeX commands, e.g. instead of typing or pasting 𝛼 (U+1D6FC MATHEMATICAL ITALIC SMALL ALPHA), write instead $\alpha$. Detexify is a useful tool for finding the LaTeX command that corresponds to a given symbol.

For emojis, you can use the \symbol command in tandem with fontspec, XeLaTeX, and a suitable font. For example:

Falling leaves: {\fontspec{Symbola}\symbol{"1F343}}

Emoji-symbola-falling-leaves.png

If you want to use colour emojis, you may want to have a look at the emoji package. You will need to change your project's compiler to be LuaLaTeX. You can then load the emoji package, and write \emoji{leaves}.

Colour-emojis.png

Further information on using emoji with LaTeX can be found in the article Inserting emojis in LaTeX documents on Overleaf.

Line Endings

Overleaf uses unix-style newline endings, \n (LF), rather than Microsoft Windows-style line endings \r\n (CRLF).

If you are using the git interface to edit your projects on Overleaf, then you can use your system's local line endings and have git translate them to unix line endings for you by enabling git's autocrlf setting.

You may also be interested in this article about how line endings are handled by the TeX processor.

Related Help Articles

Overleaf guides

LaTeX Basics

Mathematics

Figures and tables

References and Citations

Languages

Document structure

Formatting

Fonts

Presentations

Commands

Field specific

Class files

Advanced TeX/LaTeX