1

The following is the output of this MWE:

\documentclass[12pt]{article}
\usepackage[version=4]{mhchem}
\usepackage{siunitx}
\begin{document}

\ce{a = 2 \times 3}\\
\ce{a = 2 \div 3}\\
\ce{a = 2 \times b}\\
\ce{a = 2 \div b}

\end{document}

enter image description here

Note how the character is subscripted only when the character after theoperator is a number.

How would I prevent the number from being subscripted?

2 Answers2

2

Simply preventing the operators from gobbling the space after them by providing an empty argument fixes the problem:

\documentclass[12pt]{article}
\usepackage[version=4]{mhchem}
\usepackage{siunitx}
\begin{document}

\ce{a = 2 \times{} 3}\\
\ce{a = 2 \div{} 3}\\
\ce{a = 2 \times b}\\
\ce{a = 2 \div b}

\end{document}

See also: Space after LaTeX commands

Raven
  • 3,023
2

I'm not sure why you're using \ce for this: I see no reason for a and b being upright.

You can embed math mode in \ce:

\documentclass[12pt]{article}
\usepackage[version=4]{mhchem}
\usepackage{siunitx}
\begin{document}

\ce{a = $2 \times 3$}\\
\ce{a = $2 \div 3$}\\
\ce{a = $2 \times \ce{b}$}\\
\ce{a = $2 \div \ce{b}$}

\end{document}

On the other hand if the calculations are inside \ce material, I guess

\documentclass[12pt]{article}
\usepackage[version=4]{mhchem}
\usepackage{siunitx}
\begin{document}

\ce{$a = 2 \times 3$}\\
\ce{$a = 2 \div 3$}\\
\ce{$a = 2 \times b$}\\
\ce{$a = 2 \div b$}

\end{document}

is what you're looking for.

egreg
  • 1,121,712