[Tex/LaTex] Replacing Unicode non-breakable spaces by normal spaces

fontspecluatexunicodeunicode-mathxetex

I am using the Neo keyboard layout, which uses all kinds of modifier keys to input all kinds of characters (e.g. Greek letters and mathematical symbols). It also has shift+Mod3+space mapped to Unicode 0A, no-break space. From time to time it happens that I mistakenly press these buttons (while entering a space between other symbols with the same modifier keys).

Unfortunately [Lua|Xe]TeX obeys these spaces as unbreakable spaces both in normal text and in mathmode (using fontspec and unicode-math). However my editor (vim) shows the symbol like a normal space, so it is impossible to see where I made a mistake.

Is there an easy way to tell [Lua|Xe]TeX to treat no-break spaces like normal spaces?

Best Answer

\usepackage{newunicodechar}
\newunicodechar{ }{ }

In the first argument you put a NO-BREAK SPACE (U+00A0), in the second a normal space. A better definition would be

\newunicodechar{ }{~}

(again the space is NO-BREAK SPACE), so this unbreakable space will stretch or shrink wit the other spaces in the line. Of course use the first one if you want a normal space, ça va sans dire. :)

Related Question