# How to display an underscore literal in math mode? [closed]

I want to display the literal underscore character `_` in math mode because it is used in defining a variable name. I'm using the LaTeX parser that the Python Sphinx documentation generator uses, and in trying to parse a `\_` in math mode it gives this error:

``````System Message: ERROR/3 (/home/svc_citest/.hudson/jobs/build_doc/workspace/Research/Projects/doc/factors/crspAccruals/AccrualsImplementor.rst, line 83)

Syntax error: "\_"

Accruals = PreAccruals/AVG\_ASSETS
``````

I would have thought that `\_` would work in math mode as it does in text mode, but I'm getting the error...

Here is the relevant doc page for Sphinx math mode: http://sphinx.pocoo.org/ext/math.html. It is mirroring AMS LaTeX, so if you need minimal working examples in which to insert the underscores, try there.

-

## closed as off topic by egreg, lockstep, clemens, Harish Kumar, KurtOct 18 '12 at 23:32

Questions on TeX - LaTeX Stack Exchange are expected to relate to TeX, LaTeX or related typesetting systems within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

There are a multitude of questions referencing "underscore on TeX.SE" where you should find different ways of achieving an underscore. Otherwise you can try `\textunderscore` or `\rule{1ex}{.4pt}` but `\_` should work. Could you give a small example (a minimal working example (MWE)) that doesn't work for you? – Werner Oct 18 '12 at 20:36
Could you provide a minimal working example (MWE) please? For me also @ScottH.'s example compiles without errors – Benedikt Bauer Oct 18 '12 at 20:36
That is not a TeX error message. Is it your editor or some other parser that is getting confused? – David Carlisle Oct 18 '12 at 20:40
The documentation suggests that you need a double backslash, perhaps try `\\_`: sphinx.pocoo.org/ext/math.html?highlight=latex – Scott H. Oct 18 '12 at 20:45
It is OK for me in texlive 2009 ( \$ sth \_ anotherthing \$ ) But for more details check this. – Afshin Oct 18 '12 at 20:46