A LaTeX package that enables the use of unicode/utf8 characters with pdflatex without encountering encoding errors.
DeclareUnicodeCharacter is a specialized LaTeX package designed to solve the common problem of using Unicode characters in pdflatex documents. Unlike other solutions that require replacing characters with LaTeX commands or using alternative engines like XeLaTeX or LuaLaTeX, this package allows direct usage of Unicode characters while maintaining compatibility with the traditional pdflatex workflow.
The package provides declarations for over 500 Unicode characters, including Greek letters, mathematical symbols, and special punctuation, making it especially valuable for academic and scientific documents where these characters are frequently used.
When you try to use unicode characters in LaTeX documents processed with pdflatex, you often encounter errors like:
! LaTeX Error: Unicode character β (U+03B2)
not set up for use with LaTeX.
This package allows you to use these characters directly in your document.
Place the DeclareUnicodeCharacter.sty
file in one of the following locations:
- In the same directory as your LaTeX document (easiest)
- In your local texmf directory for system-wide installation:
- Linux/macOS:
~/texmf/tex/latex/
- Windows:
C:\Users\<username>\texmf\tex\latex\
- Linux/macOS:
After placing in your texmf directory, you may need to run texhash
or mktexlsr
to update the TeX database. You can test with $ kpsewhich DeclareUnicodeCharacter.sty
which should output the actual path.
- Add the package to your LaTeX preamble:
\usepackage{DeclareUnicodeCharacter}
- Use unicode characters directly in your document:
\documentclass{article}
\usepackage{DeclareUnicodeCharacter}
\begin{document}
β and other unicode/utf8 characters like α, δ, π can be used directly.
\end{document}
The package supports a wide range of unicode characters including:
- Greek letters (α, β, γ, δ, etc.)
- Mathematical symbols (∑, ∫, ∞, etc.)
- Special punctuation (—, –, ', etc.)
- Various other symbols (©, ®, ™, etc.)
See the complete list in successful-chars.pdf
.
- Compatible with pdflatex
- Not compatible with luatex
- The package was created by extracting commands from
/usr/share/texmf/tex/texinfo/texinfo.tex
- See the test file
successful-chars.pdf
which demonstrates 550+ successfully compiled characters - The repository includes
extract-test-file.py
containing utility test functions
Contributions are welcome! Here's how you can help:
- Report bugs and request features through issues
- Submit pull requests with improvements
- Help add support for more unicode characters
- Improve documentation
Please follow the existing code style and add tests for new features.
MIT