7

I've been searching for answers, found a couple but could not make them to work in my particular situation. If there is a general procedure to do the change, I'd be glad to read it. Is there a way to change a couple of symbols from one symbol set to another? More specifically, I'd like to change the sum and product operators from mtpro2 (lite) to the ones in mathptmx. It'd be great to have a new set of commands, like e.g. \newsum or \newprod for the newly-defined symbols. I'm using XeLaTeX. A basic TeX file is the one I'm posting below. Thank you.

\documentclass[14pt, a4paper, reqno]{extarticle}

\usepackage{amsmath}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\usepackage{mathptmx} \usepackage[lite]{mtpro2}

\usepackage{mathspec} \setmainfont[Scale=0.95]{Crimson Text} \setsansfont[Scale=0.8]{Ubuntu} \setmonofont[Scale=0.9]{Ubuntu Mono} \setmathsfont(Latin)[Uppercase=Italic,Lowercase=Italic,Scale=0.95]{Crimson Text} \setmathsfont(Greek)[Uppercase=Regular,Lowercase=Regular,Scale=0.85]{GFS Didot} \setmathrm{Crimson Text}

\usepackage{microtype} \usepackage{amssymb} \usepackage{amstext} \usepackage{amsthm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document}

$$\sum_{i=1}^nX_iY_{n-i}$$ $\sum_i\varphi (x_i)$

\end{document}

Anibal
  • 93
  • In unicode-math, you can \setmathfont[range={\sum, \prod, \coprod}, Scale=MatchUppercase]{TeX Gyre Termes Math} (or your math font of choice). – Davislor Jun 23 '20 at 00:07
  • Thank you Davislor. This would be a very nice solution. But I do not know why it does not work as expected in my document. As a matter of fact, I tried with \setmathfont, \setmathsfont and other fonts besides Tex Gyre Termes and the sum sign does not change at all. There are no errors after compiling, either. – Anibal Jun 23 '20 at 01:40

2 Answers2

7

With Modern Fonts

In unicode-math, you can replace these symbols with \setmathfont[range = ...]:

\documentclass{article}
\usepackage{unicode-math}

\setmathfont{Latin Modern Math} \setmathfont[range={\sum, \prod, \coprod}, Scale=MatchUppercase ]{STIX Two Math}

\begin{document}

[ \sum_{a \in \mathcal{S}} a = \prod_{b \in \mathcal{T}} b ]

\end{document}

STIX Two Math sample

With Legacy Fonts

With legacy 8-bit math fonts, you would need to look up the slot number of both the large and the small operator in the math font, load those math alphabets (of which you have only 16), and declare the command to use the appropriate large or small symbol in each of the four math modes.

The exact commands will vary from package to package, but this example imports \sum and \prod from txfonts.

\documentclass{article}

\DeclareSymbolFont{replacement-operators}{OMX}{txex}{m}{n} \DeclareMathSymbol{\bigsum}{\mathop}{replacement-operators}{"58} \DeclareMathSymbol{\smallsum}{\mathop}{replacement-operators}{"50} \DeclareMathSymbol{\bigprod}{\mathop}{replacement-operators}{"59} \DeclareMathSymbol{\smallprod}{\mathop}{replacement-operators}{"51}

\renewcommand\sum{\mathop{\mathchoice {\bigsum}% {\smallsum}% {\smallsum}% {\smallsum}}}

\renewcommand\prod{\mathop{\mathchoice {\bigprod}% {\smallprod}% {\smallprod}% {\smallprod}}}

\begin{document}

[ \sum_{a \in \mathcal{S}} a = \prod_{b \in \mathcal{T}} b ]

\end{document}

It’s trivial to change the \renewcommand declarations to \newcommand\newsum and \newcommand\newprod if you want.

Using the newtxmath symbols requires a little more digging through the source. Its extended symbol font declares an 8-bit extension of the 7-bit OMX encoding, which you must set up.

\documentclass{article}
\usepackage[T1]{fontenc}

\DeclareFontEncoding{LMX}{}{} \DeclareFontSubstitution{LMX}{ntxexx}{m}{n}

\DeclareSymbolFont{replacement-operators}{LMX}{ntxexx}{m}{n} \DeclareMathSymbol{\bigsum}{\mathop}{replacement-operators}{"58} \DeclareMathSymbol{\smallsum}{\mathop}{replacement-operators}{"50} \DeclareMathSymbol{\bigprod}{\mathop}{replacement-operators}{"59} \DeclareMathSymbol{\smallprod}{\mathop}{replacement-operators}{"51}

\renewcommand\sum{\mathop{\mathchoice {\bigsum}% {\smallsum}% {\smallsum}% {\smallsum}}}

\renewcommand\prod{\mathop{\mathchoice {\bigprod}% {\smallprod}% {\smallprod}% {\smallprod}}}

\begin{document}

[ \sum_{a \in \mathcal{S}} a = \prod_{b \in \mathcal{T}} b ]

\end{document}

Davislor
  • 44,045
6

Interacting with such different packages as mtpro2 and mathspec is not always easy. In this particular case it turns out that you shouldn't redefine \sum and \prod, but \upsumop and \upprodop.

\documentclass[14pt, a4paper, reqno]{extarticle}

% package loading

\usepackage[lite]{mtpro2} \usepackage{amsmath}

\usepackage{mathspec}

\usepackage{microtype} \usepackage{amssymb} \usepackage{amsthm}

% setup \DeclareSymbolFont{mathptmxlargesymbols}{OMX}{ztmcm}{m}{n} \DeclareMathSymbol{\upsumop}{\mathop}{mathptmxlargesymbols}{"50} \DeclareMathSymbol{\upprodop}{\mathop}{mathptmxlargesymbols}{"51}

\setmainfont[Scale=0.95]{Crimson Pro} %\setsansfont[Scale=0.8]{Ubuntu} %\setmonofont[Scale=0.9]{Ubuntu Mono} \setmathsfont(Latin)[Uppercase=Italic,Lowercase=Italic,Scale=0.95]{Crimson Pro} \setmathsfont(Greek)[Uppercase=Regular,Lowercase=Regular,Scale=0.85]{GFS Didot} \setmathrm{Crimson Pro}

\begin{document}

[\prod_{k}\sum_{i=1}^nX_iY_{n-i}]

$\prod_k\sum_i\varphi (x_i)$

\end{document}

enter image description here

Production note. I changed Crimson Text into Crimson Pro that I have available, to get a flavor of the final result. I commented out the call for the Ubuntu fonts because I presently don't have them on my system.

egreg
  • 1,121,712
  • egreg and Davislor, many thanks for your detailed answers. I'll try and post back. – Anibal Jun 23 '20 at 13:38
  • Both solutions worked! I appreciate the help you provided. – Anibal Jun 23 '20 at 14:38
  • I use the following line to add the coproduct operator \DeclareMathSymbol{\upcoprodop}{\mathop}{mathptmxlargesymbols}{"??} Is it correct? Do you know which is the number I should use for this operator? – Anibal Jun 23 '20 at 15:23
  • @Anibal "60 is the number. – egreg Jun 23 '20 at 15:49
  • Thank you for the quick replies. I used "60 but I get a black square instead of the coproduct symbol. Maybe I'm making some mistake in other part of the line? \DeclareMathSymbol{\upcoprodop}{\mathop}{mathptmxlargesymbols}{"60} – Anibal Jun 23 '20 at 16:05