1

I want to extract the plus symbol + from the newtx(which included newtxmath) package. But I want to just extract this symbol into my document, not to include the entire package (which leads to a conflict). How can I do this? For example, it seems it should be written as something like \DeclareMathSymbol{+}{...}{...}{...} to redefine the + symbol, but how can I get the font-family name of newtxmath? I checked the package document, but can't find it. At the same time, I also checked the newtxmath.sty, but hardly to understand. Need help.

2 Answers 2

7

The important lines from newtxmath.sty for the redefinition of the plus sign in math are the lines with \DeclareMathSymbol{+} and the definitions for the symbol font lettersA.

In addition, the font definition file untxmia.fd uses \if switches that reflects the options libertine, minion, and cochineal.

\documentclass{article}

\mathchardef\OldPlus=\mathcode`\+

\makeatletter
\newif\iftx@libertine
\newif\iftx@minion
\newif\iftx@coch
\makeatother
\DeclareSymbolFont{lettersA}{U}{ntxmia}{m}{it}
\SetSymbolFont{lettersA}{bold}{U}{ntxmia}{b}{it}
\DeclareMathSymbol{+}{\mathbin}{lettersA}{253}

\begin{document}
\begin{tabular}{ll}
  Old: & $\OldPlus$\\
  New: & $+$
\end{tabular}
\end{document}

Result

The case of the minus sign or \times is different. Here, package newtxmath redefines the standard symbol font symbols. Therefore, this font is renamed to NTXsymbols in the following example in order to avoid changes of other letters:

\documentclass{article}
\usepackage{booktabs}

\mathchardef\OldPlus=\mathcode`\+
\mathchardef\OldMinus=\mathcode`\-
\let\OldTimes\times

\makeatletter
\newif\iftx@libertine
\newif\iftx@minion
\newif\iftx@coch
\makeatother
\DeclareSymbolFont{lettersA}{U}{ntxmia}{m}{it}
\SetSymbolFont{lettersA}{bold}{U}{ntxmia}{b}{it}
\DeclareMathSymbol{+}{\mathbin}{lettersA}{253}

\DeclareSymbolFont{NTXsymbols}{OMS}{ntxsy}{m}{n}
\SetSymbolFont{NTXsymbols}{bold}{OMS}{ntxsy}{b}{n}
\DeclareMathSymbol{-}{\mathbin}{NTXsymbols}{0}
\DeclareMathSymbol{\times}{\mathbin}{NTXsymbols}{2}

\begin{document}
\begin{tabular}{ll}
  Old & New \\
  \midrule
  $\OldPlus$ & $+$ \\
  $\OldMinus$ & $-$ \\
  $\OldTimes$ & $\times$ \\
\end{tabular}
\end{document}

Result

7
  • Thanks! How can I mimic this way to redefine - and \times? I opened newtxmath.sty but can't find the definition of - or \times. Is there an encode table to see which character is corresponding to which encode?
    – Eric
    Feb 18, 2017 at 4:48
  • @Eric See updated answer. Feb 18, 2017 at 9:16
  • @HeikoOberdiek I can compile successfully but seems LaTeX can't get the font of $-$ and $\times$, they look like traditional Computer Modern style symbols. (So the - looks rounded-corner and apparently longer then the +). My environment: I use XeLaTeX and mtpro2 now. I have installed the newtx package(the latest version) but don't usepackage them. The + behaves successfully.
    – Eric
    Feb 18, 2017 at 10:17
  • @Eric Have you loaded mtpro2 before or after the redefinitions? Feb 18, 2017 at 11:18
  • Before. I put my test code to here (ps: the site doesn't support XeLaTeX.)
    – Eric
    Feb 18, 2017 at 11:34
6

In case you do not wish to use a maths alphabet up for a single symbol (it is not hard to plough through the 16 available), you can define a macro to access the symbol by tweaking egreg's answer and the relevant commands from pifont. Combining this with the information from Heiko Oberdiek's answer:

\documentclass{article}
% ateb egreg: https://tex.stackexchange.com/a/14406/
\usepackage{pifont}
\makeatletter
\newcommand\Pimathsymbol[3][\mathord]{%
  #1{\@Pimathsymbol{#2}{#3}}}
\def\@Pimathsymbol#1#2{\mathchoice
  {\@Pim@thsymbol{#1}{#2}\tf@size}
  {\@Pim@thsymbol{#1}{#2}\tf@size}
  {\@Pim@thsymbol{#1}{#2}\sf@size}
  {\@Pim@thsymbol{#1}{#2}\ssf@size}}
\def\@Pim@thsymbol#1#2#3{%
  \mbox{\fontsize{#3}{#3}\Piitsymbol{#1}{#2}}}
% ateb Heiko Oberdiek: https://tex.stackexchange.com/a/354435/
\newif\iftx@libertine
\newif\iftx@minion
\newif\iftx@coch
% pifont.sty
\newcommand{\Piitfont}[1]{\fontfamily{#1}\fontencoding{U}%
\fontseries{m}\fontshape{it}\selectfont}
\newcommand{\Piitsymbol}[2]{{\Piitfont{#1}\char#2}}
\makeatother
\newcommand{\newplus}{\Pimathsymbol[\mathbin]{ntxmia}{253}}

\begin{document}

\[
      + \newplus
\]


\end{document}

plus and new plus

You must log in to answer this question.

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