I need to put stellar mass data in units of Solar Mass, and I tried the M_{\odot}, but the console shows:

! missing $ inserted error.

I don't know what is wrong. Please help me out

  • 11
    You can't use subscripts in text mode. Either use $M_\odot$ or M\textsubscript{$\odot$}. May 16, 2017 at 13:01
  • 2
    Or use the wasysym package and \astrosun May 16, 2017 at 13:05
  • 3
    @Rmano NOOOO! Not the wikibook. It's crap. Read LaTeX and Friends instead! May 17, 2017 at 2:13
  • 4
    I'm voting to close this question because it was solved in the comments. May 11, 2018 at 4:15
  • 6
    @Troy the question is clearly about TeX (not off-topic), it is clear enough that although there's no MWE the problem can be recognised (not unclear), and even has an upvoted answer - why close as off-topic in the first place? Solved in comments is not a valid close reason, something like problem was just a typo which was identified in the comments can be but that doesn't strike me as the case here. Perhaps this should be closed as a dupe but that's a whole different thing.
    – Dai Bowen
    May 11, 2018 at 9:54

2 Answers 2


TeX complains with missing $ inserted because of the underscore. _ is a special character dedicated for subscripts, which require math mode.

My first example is all math mode, the second one is typesetting the M in upright text mode, the third uses text mode for the subscript. Choose for yourself whether the solar mass should be typeset in math italic—as a variable—or upright—as having a defined meaning.




  • 1
    This is a bit old but I must comment on one point: denoting _ as active character is misleading. TeX reserves this name to chars with category code 13. The underscore is a subscript character (category code 8). In your answer I would rather use "special character" to avoid issues.
    – campa
    Dec 5, 2020 at 9:23

In Unicode, the symbol you want is U+2609, and can be loaded from any font that contains it using fontspec. Here is an example using DejaVu Sans, and the output with LuaLaTeX.


\newfontfamily\symbolfont{DejaVu Sans}[Scale=MatchUppercase]


\pagestyle{empty} % Suppress page numbering.

Solar mass is denoted {\solarmass}.

DejaVu Sans sample

You must log in to answer this question.

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