What file encodings and line endings should I use?
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}}
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}
.
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
- 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