# Astrophysical notation : typeset HI

What would the best way to typeset HI to designate molecular gas as in the title of this article, with a capital H and a slightly smaller numeral I ? I am using the scrbook class.

I tried to define

\newcommand{\HI}{H {\uppercase{\romannumeral 1}} }


but this results in H i, with a lowercase i.

I also tried

\newcommand*{\HI}{\textsc{Hi}}


but this doesn't behave properly when I use it in \section{}, resulting in "H i" rather than "H I".

I also haven't found anything like this in chemmacros, which is more geared towards chemists.

This is a standard way of writing molecules in astrophysics, so I'm surprised there isn't a package that does this easily.

• it's a tex generated file on arxiv, can't you just download the tex source and see, there is no need to use \uppercase and \romannumeral they would just generate a normal I anyway so you could simply use HI – David Carlisle Mar 8 at 9:24
• perhaps \textsc{Hi} – David Carlisle Mar 8 at 9:29
• I would not recommand the way it seems in this article... The distance between H and I makes it difficult in reading as one "thing" and possibly the author would try to use another way of defining a command in future edition of this article. @DavidCarlisle's above comment would give a better result I suppose. – koleygr Mar 8 at 9:42
• The article you linked to uses H\,{\footnotesize I} - however I don't think this is the best way to go (you can download the tex source of the article from arxiv.org/format/1608.02601) – user36296 Mar 11 at 10:55
• Personally I would use the \ion macro from the "Astronomy & Astrophysics" journal class: fits.gsfc.nasa.gov/standard30/aa.cls – user36296 Mar 11 at 12:55

Use the size of subscripts linked to the current font size.

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\DeclareRobustCommand{\HI}{%
\mbox{H\check@mathfonts\fontsize\sf@size\z@\selectfont I}%
}
\makeatother

\textheight=3cm % just to shorten the image

\begin{document}

\end{document}


The kernel command \check@mathfonts computes \sf@size and \ssf@size starting from the current font size, either with the parameters stored with \DeclareMathSizes or with a heuristic otherwise.

• The spacing is off when HI is in the middle of a sentence. \HI is cool ends up in the document as HIis cool. – usernumber Jun 5 at 17:27
• @usernumber That's a well known fact; just add {} at the end: \HI{}. It is discussed in tex.stackexchange.com/q/31091/4427, but adding {} is the most effective way, notwithstanding what others suggest. – egreg Jun 5 at 17:29

Adjust 1.2ex to suit.

\documentclass{article}
\usepackage{scalerel}
\newcommand\HI{H\protect\scaleto{$I$}{1.2ex}}
\begin{document}
\tableofcontents

\section{This is \HI}

And in text: \HI{} and \LARGE \HI
\end{document}


Because scalerel operates, by default, in math mode, the $I$ is actually an escape out of math mode. If that is too confusing, you could always just operate in math mode as: \newcommand\HI{H\protect\scaleto{\textrm{I}}{1.2ex}}

If you wanted a version without packages, you could do this, but it requires a separate macro for bold style:

\documentclass{article}
\newcommand\HI{$\textrm{H}\scriptstyle\mathrm{I}$}
\newcommand\HIbold{$\textbf{H}\scriptstyle\mathbf{I}$}
\begin{document}
\tableofcontents

\section{This is \HIbold}

And in text: \HI{} and \LARGE \HI
\end{document}


Another way to do it is the way it is implemented by the Astronomy & Astrophysics class.

\DeclareRobustCommand{\ion}[2]{%
\relax\ifmmode
\ifx\testbx\f@series
{\mathbf{#1\,\mathsc{#2}}}\else
{\mathrm{#1\,\mathsc{#2}}}\fi
\else\textup{#1\,{\mdseries\textsc{#2}}}%
\fi}


Then in the body of the document, use

\ion{H}{I}