TransWikia.com

How do I input the symbol for Solar Mass?

TeX - LaTeX Asked by Hansatanu Roy on February 22, 2021

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

2 Answers

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.

documentclass{article}
tracinglostchars=2
usepackage{fontspec}

newfontfamilysymbolfont{DejaVu Sans}[Scale=MatchUppercase]

newcommandastrosun{{symbolfontsymbol{"2609}}}
newcommandsolarmass{ensuremath{mathrm{M}_{textnormal{astrosun}}}}

pagestyle{empty} % Suppress page numbering.

begin{document}
Solar mass is denoted {solarmass}.
end{document}

DejaVu Sans sample

Answered by Davislor on February 22, 2021

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.

documentclass{article}

begin{document}
(M_odot)
or
(textup{M}_odot)
or
Mtextsubscript{(odot)}
end{document}

screenshot

Answered by lblb on February 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP