Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

2 Answers

up vote 9 down vote accepted
\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. :)

share|improve this answer

Another solution will be to change vim setup so that you can see the non-breakable space.

set listchars=nbsp:¬
set list

You can set appropriate syntax highlighting for NonText to highlight the non-breakable space.

share|improve this answer
Great. Though I'll use ␣, as it has less chance of being actually used in the (math) text. – Caramdir May 16 '11 at 22:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.