# Subscript in siunitx fraction mode

I would like to automate my SI Units a bit. Unfortunately I'm not getting the desired result if I add subscript text. I tried multiple versions with \text and similiar functions. How can I display a fraction with subscripts with siunitx?

\documentclass[
fontsize=12pt,
paper=a4,
oneside,
leqno
]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage[
fleqn
]{amsmath}

\usepackage{siunitx}
\sisetup{
locale = DE,
per-mode=fraction,
quotient-mode=fraction,
fraction-function=\tfrac
}

\NewDocumentCommand\DeclareNewQuantity{mmm}{%
\DeclareSIUnit{#2}{#3}%
\DeclareDocumentCommand{#1}{O{}m}{\SI[##1]{##2}{#2}}%
}

\DeclareNewQuantity
\DoesWhatIWant
\doesWhatIWant
{\kg\per\kg}
\DeclareNewQuantity
\DoesNotWhatIWant
\doesNotWhatIWant
{\kg_{H2}\per\kg_{FeTi}}

\begin{document}

$\DoesWhatIWant{1,2345}$

$\DoesNotWhatIWant{1,2345}$

\end{document}


The result looks like this:

The second should look like the first output.

Decalre \kg_{H2} and \kg_{FeTi} as new units with \DeclareSIUnit first.

\DeclareSIUnit\kgh{\kg_{H2}}
\DeclareSIUnit\kgfe{\kg_{FeTi}}


\documentclass[
fontsize=12pt,
paper=a4,
oneside,
leqno
]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage[
fleqn
]{amsmath}

\usepackage{siunitx}
\sisetup{
locale = DE,
per-mode=fraction,
quotient-mode=fraction,
fraction-function=\tfrac
}

\DeclareSIUnit\kgh{\kg_{H2}}
\DeclareSIUnit\kgfe{\kg_{FeTi}}

\NewDocumentCommand\DeclareNewQuantity{mmm}{%
\DeclareSIUnit{#2}{#3}%
\DeclareDocumentCommand{#1}{O{}m}{\SI[##1]{##2}{#2}}%
}

\DeclareNewQuantity
\DoesWhatIWant
\doesWhatIWant
{\kg\per\kg}
\DeclareNewQuantity
\DoesNotWhatIWant
\doesNotWhatIWant
{\kgh\per\kgfe}

\begin{document}

$\DoesWhatIWant{1,2345}$

$\DoesNotWhatIWant{1,2345}$
\end{document}

• Perfect :) Thank you! – Kilian Helfenbein Oct 29 '19 at 9:45
• Very ugly this answer wih 0 score. My sincere compliments. – Sebastiano Oct 29 '19 at 15:30