# siunitx: Warning “\textsuperscript invalid in math mode” and missing spaces [closed]

Is there a reasonable explanation for those warnings/errors?

How can I avoid them properly?

If I use pdfLaTeX, I get the same (incorrect) output, but no warning.

%!TEX TS-program = lualatex
\documentclass[fleqn]{scrartcl}

\usepackage{fontspec, polyglossia}
\setdefaultlanguage[spelling=new, babelshorthands=true]{german}

\usepackage{mathtools}
\usepackage{siunitx}

\begin{document}

%Warning: LaTeX Warning: Command \textsuperscript invalid in math mode on input line XYZ
%The non-marked lines are ok

$\SI{1}{\cm^3 \per \min}$
$\SI{1}{\cubic \cm \per \min}$ %warning
$\SI{1}{\square\cm\per\min}$ %warning
%$\SI{1}{cm^2 \per. min}$
$\SI{1}{\cm^2 \per \min}$
$\SI{1}{\N \cm\tothe{3} \kilo \mol\squared}$
$\SI{1}{\N \cm\tothe{3} \min}$ %warning and visibly missing space between N cm
$\SI{1}{\cm\tothe{3} \min}$ %warning
$\SI{1}{\cm\cubed \per \min}$ %warning
$\SI{1}{\N \cm \tothe{3} \kilo \gram \squared}$

$\SI{1}{\N \cm \tothe{3} \kilo \gram \squared}$
$\SI{1}{\N \cm \tothe{3} \kilo \mol \squared}$

\end{document}


## closed as off-topic by LaRiFaRi, Zarko, Svend Tveskæg, Kurt, barbara beetonMar 15 '16 at 14:57

• This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• The explanation is simple: fontspec loads xunicode that redefines \textsuperscript in a way that makes TeX issue that warning. – egreg Jun 1 '15 at 16:40
• I told Joseph Wright about this issue in chat:chat.stackexchange.com/transcript/message/21953530#21953530 – egreg Jun 1 '15 at 16:49
• While not a robust fix, you could use ~ when you are missing a space and can't seem to do much about it. $\SI{1}{\N~\cm\tothe{3} \min}$ %warning and visibly missing space between N cm – EngBIRD Jun 13 '15 at 20:15
• I did not think of that one yet. So far, i just used \SI{1}{N.cm^3.min} to avoid that warning and get the spaces. – Matthias Jun 15 '15 at 17:05
• I'm voting to close this question as off-topic because it is about an issue which has been solved in v2.6f (github.com/josephwright/siunitx/commit/…) – LaRiFaRi Mar 15 '16 at 14:28