4

Using the luatexja-fontspec package for LuaLaTeX leads to unwanted space between the 'minus' and the number in the exponent of numbers/units typed with the sinunitx package using the options mode=text and detect-all. This Problem does not occur when I remove these options or when I remove luatexja-fontspec.

\documentclass{scrbook}
\usepackage{fontspec}
\usepackage{luatexja-fontspec}
\usepackage[
    mode=text,
    detect-all,
]{siunitx}

\begin{document}
\SI{2.5e-10}{mol.L^{-1}}
\end{document}

Does someone have a solution to get rid of this unneccessary space? Or do I have to switch to another package for asian characters? (I need a package that recognizes asian characters automatically without typing them inside enviroments or commands. And I definitely need siunitx with a proper output.)

1 Answer 1

3

With luatexja the minus used by siunitx here is a so-called JAchar and is replaced with the lua code. You can change this status either globally -- this can affect text outside siunitx too, or inject a \ltjalchar so that it is treated as ALchar instead.

\documentclass[parskip=true]{scrbook}

\usepackage{luatexja-fontspec}
\usepackage[mode=text,detect-all]{siunitx}


\begin{document}

\SI{2.5e-10}{mol.L^{-1}} \\
\char8722 10


%general change
\ltjdefcharrange{1}{"2212}

\SI{2.5e-10}{mol.L^{-1}} \\
\char8722 10

%back to default
\ltjdefcharrange{3}{"2212}

\SI{2.5e-10}{mol.L^{-1}} \\
 \char8722 10


\ExplSyntaxOn
%local solution, put inside \AtBeginDocument in the preamble
 \tl_set:Nn \c__siunitx_minus_tl {\ltjalchar`\^^^^2212}
\ExplSyntaxOff

\SI{2.5e-10}{mol.L^{-1}} \\
\char8722 10
\end{document}

enter image description here

You could also make a feature request for luatexja. They could add the patch for siunitx.

3
  • Thank you, this works. However, I get several error messages when I place the ExplSyntax part within \AtBeginDocument{...} into the preamble (! Undefined control sequence. \begin{document}, Missing $ inserted, ! Double subscript. \begin{document}, ! TeX capacity exceeded, sorry [input stack size=5000].)
    – Lysanne
    Mar 19, 2018 at 17:14
  • \ExplsyntaxOn must be before \AtBeginDocument{} and the off command behind. Mar 19, 2018 at 17:15
  • Yes, you're right, and it must be placed after siunitx is loaded otherwise it has no effect. Now it works.
    – Lysanne
    Mar 19, 2018 at 17:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .