I am using starfont
to get astronomical symbols in my document. Unfortunately, the package defines the symbols for text mode only. From this answer, I was able to declare math versions of the symbols and came up with this MWE:
\documentclass{article}
\usepackage[amsthm, libertine, varbb]{newtxmath}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage[starfontserif]{starfont}
\DeclareSymbolFont{starfontsym}{OT1}{sts}{m}{n}
\DeclareMathSymbol{\mathSun}{\mathord}{starfontsym}{115}
\DeclareMathSymbol{\mathMercury}{\mathord}{starfontsym}{102}
\DeclareMathSymbol{\mathVenus}{\mathord}{starfontsym}{103}
\DeclareMathSymbol{\mathTerra}{\mathord}{starfontsym}{76}
\DeclareMathSymbol{\mathvarTerra}{\mathord}{starfontsym}{108}
\DeclareMathSymbol{\mathMoon}{\mathord}{starfontsym}{100}
\DeclareMathSymbol{\mathvarMoon}{\mathord}{starfontsym}{97}
\DeclareMathSymbol{\mathMars}{\mathord}{starfontsym}{104}
\DeclareMathSymbol{\mathJupiter}{\mathord}{starfontsym}{106}
\DeclareMathSymbol{\mathSaturn}{\mathord}{starfontsym}{83}
\DeclareMathSymbol{\mathUranus}{\mathord}{starfontsym}{70}
\DeclareMathSymbol{\mathvarUranus}{\mathord}{starfontsym}{65}
\DeclareMathSymbol{\mathNeptune}{\mathord}{starfontsym}{71}
\DeclareMathSymbol{\mathPluto}{\mathord}{starfontsym}{74}
\DeclareMathSymbol{\mathvarPluto}{\mathord}{starfontsym}{72}
\begin{document}
\begin{tabular}{rcc}
Sun & \Sun \\
Mercury & \Mercury \\
Venus & \Venus \\
Earth & \Terra & \varTerra \\
Moon & \Moon & \varMoon \\
Mars & \Mars \\
Jupiter & \Jupiter \\
Saturn & \Saturn \\
Uranus & \Uranus & \varUranus \\
Neptune & \Neptune \\
Pluto & \Pluto & \varPluto
\end{tabular}
\begin{align}
& \mathSaturn : g_\mathSaturn, \quad \mathTerra : g_\mathTerra
\end{align}
\begin{align}
&\frac{\Delta m_\mathSaturn}{m-m_\mathTerra} = \left( 1 - e^{-\frac{\Delta v_\mathSaturn}{I_{\mathrm{sp}}g_\mathTerra}} \right)
\end{align}
\[ M_{\mathSun} = \SI{1.989e33}{\gram} \qquad M_{\Sun} = \SI{1.989e33}{\gram} \]
\[ M_{\mathTerra} = \SI{5.9722e27}{\gram} \qquad M_{\Terra} = \SI{5.9722e27}{\gram} \]
\[ M_{\mathMoon} = \SI{7.342e25}{\gram} \qquad M_{\Moon} = \SI{7.342e25}{\gram} \]
\[ M_{\mathVenus} = \SI{4.8673e27}{\gram} \qquad M_{\Venus} = \SI{4.8673e27}{\gram} \]
\end{document}
which gives me:
I have two problems with this setup that I'd like to address:
- Using the regular symbols in math mode does work, but produces the wrong symbols. It's very easy to type
\Sun
instead of\mathSun
so I can see myself making this mistake multiple times. I'd prefer to get a warning or an error whenever I try to use the regular symbols in math mode to avoid this mistake. - Having two separate versions of the same symbol isn't nice. I'd prefer to have a single
\Sun
command which would produce the text version in text mode and the math version in math mode. Obviously, this would solve the first issue as well, and it would be a better experience to have a single command that adapts to the environment it's used in.
Is there a way to patch or modify those commands to work correctly in math mode? If not and I really must have two versions of each symbol, then is it at least possible to make the text versions issue a warning if used in math mode?