I have been trying to copy and paste some code into LyX (via the 'Program Listings' menu item), and when I compile the document I get the LyX error:

Could not find LaTeX command for character '' (code point 0x2009)

LyX also suggested I convert the document I am attempting to copy and paste to UTF-8. However, I ran a file --mime <mycodefile.py> and a file --mime <mycodefile.py> and both return charset=us-ascii.

Correct if I'm wrong, but isn't ascii a subset of UTF-8? If so, where is this offending 0x2009 character coming from, and how to I fix this issue?


Note: instead of copying and pasting, I tried using 'Insert> File > Plain Text ...', and I got the same error. So it's not like the text is being reencoded somehow in the clipboard.


for some reason, after restarting lyx i could compile (slaps forehead). when I copy/pasted originally, the encoding may have been unicode, but then I cntl-Z'd and switched it to UTF-8 using vim. This error somehow persisted until restart.

  • Restarting does seem to help, even if you just deleted the offending spaces. – freespace Aug 21 '13 at 11:06
  • I am getting this error even for text that is after \end{document}. Is there a way around this? – Manu May 13 '19 at 16:42

The error is somewhat misleading as one might read the quotation mark as the offending character, when in fact the actual offending character is a thin space (see http://www.unicodemap.org/details/0x2009/index.html).

When copying from certain applications such as Adobe Reader, unicode characters such as thin and thick spaces, en-dashes, and ellipsis are copied. The problem arises when pasting this into LyX (and other text editors). These accept unicode characters as valid plain text characters even if LaTeX does not map them to the relevant characters in the fonts and it will happen regardless of the encoding chosen in the documents source code.

I do not have a general solution to your problem other than hunting down the offending spaces and replacing them with regular spaces, which is a quite tedious task. For a longer text you should use search and replace. I hope others can suggest a more automated solution.

  • can't LaTeX handle any UTF-8 character? I thought 0x2009 was unicode. in any case, thanks for your answer. I tried a cat <filename> | sed -e s/\x2009/ /g – nbren12 Apr 11 '12 at 21:37
  • @nbren12 LaTeX can handle some unicode characters, but two conditions must be met: i) The document source code must be UTF-8, and ii) the unicode character in question must be mapped to a symbol in a font. The inputenc package handles this, but not all unicode characters are mapped. – spet Apr 11 '12 at 21:48

Paste code into a text editor and save as ANSI. Then find the characters that aren't properly displayed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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