Working with LaTeX, I often have a compilation error when writing exponentials in mathematical expressions, even though the syntax is valid. Recently I discovered this was due to a 'Backspace' character (ASCII 0x08) that is typed by mistake, but doesn't appear in my IDE (TeXstudio, and more recently I've made LaTeX flashcards in Anki and I had the same problem).

I have a Canadian Multilingual Standard keyboard. In order to do the caret ^ character to write exponents, I press ^ (the key to the right of P), release then press Space. But sometimes I type too fast, I make a mistake and I want to go back, so I press ^ then Backspace right away, which inserts the infamous 'Backspace' character even though it's not displayed. pdfLaTeX will fail to compile because of the invisible character, so I have to copy/paste into Sublime Text (which displays the control character BS) or in Notepad (which displays a little box), erase a full line and type the text a second time before copying it again in my LaTeX editor.

This is very time consuming, so I'm hoping there is an easier way to solve the problem (besides not making any mistake when typing). Ideally, pdfLaTeX would simply ignore the 0x08 character and compile anyway. Perhaps I have to add something to the preamble regarding the character encoding? Or if there were a way to display the control character in TeXstudio and Anki like Sublime Text and Notepad do, at least I would spot the mistake right away without having to copy/paste in another editor.

Final comment: I thought the problem might be how my CMS keyboard is configured, since the combination ^, Backspace should not insert a 'Backspace' character. But I noticed the behaviour of this combination depends on the program I'm using: Notepad and Word do nothing, Sublime Text and TeXworks - which I don't like to use - delete the last character (like a simple Backspace), SE editor inserts a ^, etc. So the problem seems to come from some IDEs themselves (although I don't care much if the 0x08 character is inserted but I can find a way to ignore it when compiling).

1 Answer 1


LaTeX allows you to assign to each character a so-called catcode (category code), that determines how that character then is handled internally. This works for visible but also for invisible characters. The syntax for that is \catcode<char number>=<catcode number>.

You now have several options what to do with that character. Here are some ideas (note the (invisible) backspace characters between Invisible and backspace):


% 10 = Make it an ordinary space character, like '\x20'

% 9 = Ignore the character completely

% 13 = Make the character "active", i.e. treat it like a macro name
% ... and define a macro that adds a visual hint about that character in the final output

enter image description here

Note the \def^^H{...}, where ^^H is an alternative way to input the character '\x08'. The character position of H is 72 of which LaTeX subtracts 64 here to get to position 8.

  • It's a nice workaround. However Anki prevents the use of catcode in the header of flashcards. Instead it suggests putting the command in a separate package then importing that package. It works, but I would prefer not to modify an existing package.
    – Jasmeru
    Commented Aug 28, 2018 at 2:59
  • 3
    @Jasmeru You can of course put that definition into an extra .sty file, see this thread about how to write package files
    – siracusa
    Commented Aug 28, 2018 at 3:14
  • This is an excellent answer. Commented Aug 28, 2018 at 11:21

You must log in to answer this question.

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