I'm facing a weird problem when trying to compile a PDF that contains a quoted word that starts with "r" while using the babel package in Spanish and monospace fonts.

This minimal example




Fails with error

! Bad character code (-1).
\es@chf ->\char \hyphenchar \font
l.5 \texttt{"rword"}
A Unicode scalar value must be between 0 and "10FFFF.
I changed this one to zero.

The same document renders correctly if I either

  1. remove \usepackage[spanish]{babel} (need to render twice, though),
  2. use \usepackage[ensligh]{babel},
  3. remove the monospace formatting ("rword" instead of \texttt{"rword"})
  4. remove the quotes(\texttt{rword} instead of \texttt{"rword"})
  5. remove the "r" (\texttt{"word"} instead of \texttt{"rword"}) or change it to any other letter.

Adding any amount of spaces between the quote and the letter "r" still triggers the error.

And while other letters besides "r" do compile, some of them result in weird output. For example, this is the output from \texttt{"aword"}

A period, followed by a small superscript "a", then a normal-size "word", ending with a quotation mark, all with no spaces

I tried basically all LaTeX engines available on Texmaker (XeLaTeX, LuaLaTeX, PDFLaTeX and LatexMk) and they all fail with the same error. At this point I'm just baffled and confused by the specificity of this error.

  • 3
    Never use " for quotes in TeX.
    – egreg
    Oct 25, 2021 at 14:11
  • 2
    like many babel languages spanish makes " a shorthand to access various accents and language features, you can disable that with \shorthandoff Oct 25, 2021 at 14:11
  • You also, by the way, probably want to add either \usepackage{fontspec} on XeLaTeX or LuaLaTeX, or \usepackage[T1]{fontenc} on PDFLaTeX. (But you probably left that out just to keep the MWE truly minimal.)
    – Davislor
    Oct 25, 2021 at 14:15
  • 2
    Also note that, in TeX, "rword" would display as ”rword”, inside two pairs of closing quotes. You almost certainly meant to write `` before r.
    – Davislor
    Oct 25, 2021 at 14:31

1 Answer 1


This problem is caused by the babel Spanish shorthand for ". Loading the package with


solves the problem. You could also temporarily disable it with \shorthandoff (as David Carlisle mentioned in a comment) and back on with \shorthandon. You would probably define an environment that does this and also switches to \ttfamily. You can also turn off only that one shorthand, if you need others. However, if you’re writing in Spanish as your main language, you can probably type in all the characters you need on your keyboard and do not need shorthands.

You can also tell babel that this particular "r is not a shorthand by writing


However, in TeX, " is always a closing quote (when it’s not a special character), so you might have meant to load either \usepackage{fontspec} or \usepackage[T1]{fontenc} and write

``rword" or “rword”

This is probably why the package found it acceptable to define "a, etc., as shorthands in the first place.

If you really do mean to display the exact syntax of a command with straight quotes verbatim in a monospace font, you might want to use the verbatim environment instead.

  • 3
    Thanks, this solved it. (now the document doesn't compile due to other errors; that's progress for you 🙃) Oct 25, 2021 at 14:23
  • 1
    @ElioCampitelli Progress!
    – Davislor
    Oct 25, 2021 at 19:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .