Tx · LaTeX & TikZ

Fix the LaTeX Unicode Character ≤ Error

Published By the 9to5Science editorial team

At a glance

  1. 1. Find the character

    Search the source for the literal ≤, including text copied from websites or documents.

  2. 2. Use a LaTeX command

    Replace it with \leq inside math mode, such as a \leq b.

  3. 3. Check the compiler

    For pdfLaTeX, use supported input and font encodings; XeLaTeX and LuaLaTeX handle Unicode differently.

The message Unicode character ≤ (U+2264) not set up for use with LaTeX usually appears when pdfLaTeX encounters a literal less-than-or-equal sign in your source. The character may be easy to overlook because it was pasted from a web page, PDF, email, or word processor.

The simplest fix is to write the relation using LaTeX’s math command instead of typing the Unicode character. This also makes the source more portable between LaTeX engines.

Replace the literal character in math

Use \leq (or its equivalent \le) inside math mode. For example, change:

The condition is x ≤ 5.

to:

The condition is $x \leq 5$.

A complete pdfLaTeX example is:

\documentclass{article}
\usepackage[utf8]{inputenc} % Often optional with current LaTeX releases

\begin{document}
The condition is $x \leq 5$.
\end{document}

The \leq command produces the mathematical relation. It must be used in math mode, such as between $...$, \(...\), or a displayed equation environment. \le is an accepted shorter equivalent.

Find the unnoticed character

Search the .tex file for ≤. If your editor supports searching by Unicode code point, look for U+2264. Check the main document and any included files, such as files loaded with \input or \include. Also check copied text in captions, headings, tables, bibliography entries, and comments if the character might have been moved into active document text.

If the character is in ordinary prose, decide whether it is meant as a mathematical relation. Usually it should still be written in math mode: values are $x \leq 5$. Do not simply replace it with the ASCII characters <= unless that is the notation you actually want to display.

If you need to keep the literal ≤

With pdfLaTeX, you can tell LaTeX how to interpret the character by adding this to the preamble:

\DeclareUnicodeCharacter{2264}{\ensuremath{\leq}}

The number 2264 is the hexadecimal Unicode code point for ≤. \ensuremath makes the replacement work whether the character occurs in text or already in math mode. This is a compatibility workaround; replacing the source character with \leq is usually clearer and avoids depending on the mapping.

Another option is to compile with XeLaTeX or LuaLaTeX, which read Unicode source directly. You will still need a font containing the character, and mathematical symbols are best entered with the appropriate math commands. Switching engines alone does not guarantee that every font or package will support every Unicode symbol as intended.

Common mistakes

  • Adding \usepackage[utf8]{inputenc} and expecting every Unicode symbol to work. UTF-8 specifies how characters are encoded; it does not automatically provide a LaTeX definition for every character. In recent LaTeX releases UTF-8 is the default for pdfLaTeX, but unsupported characters can still trigger this error.
  • Using \leq outside math mode. Write $a \leq b$ in running text, or use a math environment for a displayed relation.
  • Changing the file encoding without changing the character. Saving the file as UTF-8 may be appropriate, but it does not necessarily resolve a missing character mapping in pdfLaTeX.
  • Replacing every Unicode character blindly. If other symbols trigger similar errors, identify each character and choose the appropriate LaTeX command or engine setup rather than applying an unrelated substitution.

References

  1. The LaTeX2e unofficial reference manual: inputenc package
  2. CTAN: inputenc package

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.