The mathptmx package is not the best way to load the times font as the fonts are both incomplete and a patchwork of symbols from different sources.
Among the free fonts, you best choice today is probably newtx (alternatively, on older distributions, you have txfonts, but they have some spacing problems):
\documentclass{article}
\usepackage{newtxtext}
\usepackage{newtxmath}
\begin{document}
$y = f(x)$
$\mathbf{y=f(x)}$
{\boldmath$y=f(x)$}
\end{document}
XeTeX introduced new primitives such as \Umathcode
(up to version 0.9998 called \XeTeXmathcode
, renamed for compatibility with LuaTeX) that's the Unicode analog of \mathcode
.
What does \mathcode
in traditional TeX? A declaration such as
\mathcode`+="202B
tells TeX that a +
in math mode should be treated as a binary operation symbol (leftmost byte "2
), taken from font family "0
and slot "2B
in the corresponding font. In the same vein, one can say something like
\Umathcode`∑="1 "1 "2211
or even
\Umathcode`∑="1 "1 `∑
The primitive \Umathcode
has the syntax
\Umathcode<Unicode point> = <math type> <family> <slot>
After the (optional) =
, three numbers should be given, because packing the information into a single number as done by TeX is not possible. Actually the information is still packed into a single number (in this case it's decimal 18883089, hexadecimal "1202211
), but the translation from packed number to explicit type-family-slot is not straightforward.
This will be probably accompanied by a similar declaration
\Umathchardef\sum="1 "1 "2211
so that typing $∑$
or $\sum$
will give the same result.
The unicode-math
package loads a huge list of symbols and performs assignments similar to the one for ∑
. The number corresponding to ∑
will be different, because it depends on many aspects which can't be covered in a short answer.
Actually unicode-math
does much more than this, because it sets things up so that commands such as \mathbf
or \mathrm
give the desired result.
There are other primitives corresponding to the traditional ones, namely \Umathchar
, for using a directly specified character, or \Udelimiter
for setting delimiters with normal and large variant, \Umathaccent
and finally \Uradical
for defining root symbols. See texdoc xetex
that will open “The XeTeX reference guide” by Will Robertson and Khaled Hosny.
Best Answer
STIX Two Math has (almost) full coverage for upright text; you can use it together with the STIX Two Text fonts.
Math specific characters are of course missing from the Text fonts.