I'm using docutils to generate LaTeX files, with custom roles for using latex specific commands in the rst files.

My problem is, that docutils automatically escapes underscores in the parameters of the custom commands. E.g.


becomes (after expanding the internal macros)


This generates an error.

I want to avoid patching docutils. Is there a way to 'unescape' the underscore in latex? Also, is there a general way to do this for other escaped characters?

  • \edef\_{\string_} would work, if you also use \_ to typeset an _ make sure you have \usepackage[T1]{fontenc} – David Carlisle Oct 5 '14 at 18:50

You can patch \@citex (which is executed in a group) to say \def\_{_}. In this way other usages of \_ won't be affected. Doing it \AtBeginDocument is necessary, because it's there that natbib redefines \@citex.

  author={A. Uthor},




enter image description here

| improve this answer | |

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.