4

I am trying to use newtx and fontspec on XeLaTeX, and it looked OK until I used siunitx. The problem is negative signs are not printed by \num etc. How can I fix this?

Here is MWE:

\documentclass{article}
\usepackage[no-math]{fontspec}
\usepackage{zxjatype} % For printing Japanese. Requires fontspec.
\usepackage[ipaex]{zxjafont} % Set Japanese font.
\usepackage{newtxtext,newtxmath}
\usepackage{siunitx}
\sisetup{
  detect-family=true,
  detect-weight=true,
  detect-mode=true,
  detect-inline-family=math,
  detect-inline-weight=math,
  detect-display-math=true,
  output-quotient=\ensuremath{/},
}
\begin{document}
\textminus % OK

\num{-1e-1} % negative sign is not printed
\end{document}

Though my problem can be reproduced without zxjatype and zxjafont, I included them in the above example because it may be also affect my problem.

Background
I want to create a plot to include in my pLaTeX (Japanese LaTeX) document with a Python library matplotlib, which allows you to typeset text with XeLaTeX but not pLaTeX. Because XeLaTeX can also typeset Japanese text, I decided to use XeLaTeX to typeset Japanese in matolotlib. Because my main document is written in pLaTeX, which has better support on Japanese but does not support fontspec, I want to use newtxtext on both engines. I do not want to use TeX Gyre Termes or Times on fontspec because some glyphs have very different shapes compared to newtx (e.g. \textmu).

2 Answers 2

1

Well you can reset the minus sign:

\documentclass{article}
\usepackage[no-math]{fontspec}
\usepackage{newtxtext,newtxmath}
\usepackage{siunitx}
\sisetup{
  detect-family=true,
  detect-weight=true,
  detect-mode=true,
  detect-inline-family=math,
  detect-inline-weight=math,
  detect-display-math=true,
  output-quotient=\ensuremath{/},
}

\ExplSyntaxOn
\AtBeginDocument{
\tl_set:Nn \c__siunitx_minus_tl
            { \textminus }
        }
\ExplSyntaxOff

\begin{document}
\num{-1e-1} % negative sign is not printed
\end{document}

enter image description here

But imho it is a rather bad idea to use T1-encoding as main encoding with xelatex. Quite probably more symbols will "disappear".

4
  • Namely all non-ascii characters will disappear, cf. tex.stackexchange.com/questions/102525/… Dec 4, 2015 at 12:25
  • @Henri Menke: Not all non-ascii characters, at least not with a T1-encoded font as in this example. But e.g. the ß will be wrong. (One can repair/add non-ascii chars with \catcode\ß=13 \defß{\ss}` but it can get tiresome) Dec 4, 2015 at 12:34
  • What do you mean by "more symbols will disappear"?
    – a user
    Dec 7, 2015 at 14:41
  • Well try out euro or an emdash: € —. You can repair this, but you need to understand what's happening. You probably will also run into problems with copy & paste from the pdf. Dec 7, 2015 at 15:40
1

You shouldn't use newtx, but rather a Times-like text font

\documentclass{article}
\usepackage{newtxmath}
\usepackage[no-math]{fontspec}
\usepackage{zxjatype} % For printing Japanese. Requires fontspec.
\usepackage[ipaex]{zxjafont} % Set Japanese font.
\setmainfont{TeX Gyre Termes}
\usepackage{siunitx}

% see http://tex.stackexchange.com/a/279466/4427    
\DeclareSymbolFont{operators}{\encodingdefault}{\familydefault}{m}{n}

\sisetup{
  detect-family=true,
  detect-weight=true,
  detect-mode=true,
  detect-inline-family=math,
  detect-inline-weight=math,
  detect-display-math=true,
  output-quotient=\ensuremath{/},
}
\begin{document}

\textminus % OK

\num{-1e-1}

$\sin(\pi/3)\approx 0.866$

\end{document}

enter image description here

1
  • @krnk Indeed, I'm just using the math fonts of NewTX.
    – egreg
    Dec 7, 2015 at 7:40

You must log in to answer this question.

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