# How to use \newfam properly?

Consider the following example:

\newfam\myfam
\font\myfont=msam10
\textfont\myfam=\myfont
$A\mathchar"2850 B$
\end


Notice that family "8" is specified explicitly, because \mathchar allows only explicit hexadecimal digits. How to use family allocated by \newfam?

• note that \mathchar does not require hex, any tex <number> is OK, it is conventional to use hex after a " but only to make it easier for humans to break up the number. – David Carlisle Jul 17 '19 at 9:49

You can construct the number eg:

\newfam\myfam
\font\myfont=msam10
\textfont\myfam=\myfont
\def\hex#1{\ifcase#10\or1\or2\or3\or4\or5\or6\or7\or8\or9\or A\or B\or C\or D\or E\or F\fi}

$A\mathchar"2850 B$

$A\mathchar"2\hex\myfam 50 B$
\end

• \numexpr#1\relax is a safer way to have a number and not add extra space token or expand into the 0 but I stuck to classical plain tex here. The token defined by \newfam is always safe in this context. – David Carlisle Jul 17 '19 at 9:45
• I don't understand what is the meaning of "to have a number and not add extra space token or expand into the 0". Please give an example. – Igor Liferenko Jul 18 '19 at 1:16
• if you try to use this \hex with a literal digit instead of \myfam then hex{1} would start off \ifcase10... and do the wrong thing, you could define it as \ifcase#1 0\or... then \ifcase{1} would be \ifcase1 0\or... and do the right thing, but \hex\myfam would then add a space so you would get \mathchar"2 850 which would fail again. \ifcase\numexpr#1\relax0... always works but needs etex. – David Carlisle Jul 18 '19 at 6:58