It looks like siunitx
(by @Joseph Wright) has a limitation regarding complex numbers with exponents:
\documentclass[]{article}
\usepackage[]{siunitx}
\begin{document}
\num{1 + 2 i}\\ %ok, complex number
\num{2e6}\\ %ok, number with exponent
\num{1 + 2e6 i}\\ %not ok, ! siunitx error: "invalid-token-in-exponent"
\end{document}
Is there a workaround for this?
The only way I found is
\num[parse-numbers=false]{1 + (\num[parse-numbers=true]{2e6}) i}
which defeats the purpose.
(I am using siunitx
version 2.5c.)
Note that siunitx
can handle exponents in complex number, but in the case that the exponent is the same for both parts, for example \num{1+2i e10}
, which is a different case.
Best Answer
The number parser in
siunitx
is intended to support the primary purpose of the package: typesetting physical quantities (numbers with units). These rarely have a complex part, and when they do (such as in some parts of electronics) the magnitude of the real and complex parts is normally similar. Thus the package understandsas
as this is by far the most common requirement.
In principal the parser can be extended to cope with a wider range of inputs, but this also requires changes in how the output is generated. There is then a balance both in terms of complexity of code and of performance, as the 'common case' does not need any of this.
Feature requests are always welcome: please feel free to log one in the tracker, along with links to whatever input syntax(es) would be useful!