# “Missing \begin{document}” after DeclareUnicodeCharacter

When compiling this file:

\documentclass{article}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{27e3}{somereplacement}
\begin{document}

Hi, world! P ⟣ Q

\end{document}


I get the following output:

> pdflatex test.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014/Debian) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2014/05/01>
Babel <3.9k> and hyphenation patterns for 2 languages loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/utf8.def
(/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.dfu)
(/usr/share/texlive/texmf-dist/tex/latex/base/ot1enc.dfu)
(/usr/share/texlive/texmf-dist/tex/latex/base/omsenc.dfu)))

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...

l.3 ...lareUnicodeCharacter{27e3}{somereplacement}


The solution is that I should spell 27E3 in uppercase.
• No, I agree with the principle, but I thought this was stretching it a bit when the error is caused by mistyping the hexadecimal number. I think it would be much better if you asked a question like "Why do hexadecimal numbers for unicode glyphs have to be typed with uppercase letters?" and then provide a MWE with 27e3 and 27E3 to show the difference. Then some TeX wizard can enlighten us about why this is so. – Sverre Jun 4 '15 at 20:37