# Just use one single math symbol without loading a whole font [duplicate]

How can I change the code above to obtain the glyph without loading several fonts?.. If it is possible. :-)

\documentclass[12pt]{article}

% Source: https://tex.stackexchange.com/a/40767/6880
\newcommand{\PrintMathFonts}{%
\count255=0
\loop\ifnum\count255<16
(\the\count255:~\fontname\textfont\count255)

\repeat}

\DeclareFontFamily{U}{mathb}{}
\DeclareFontShape{U}{mathb}{m}{n}{
<-5.5> mathb5
<5.5-6.5> mathb6
<6.5-7.5> mathb7
<7.5-8.5> mathb8
<8.5-9.5> mathb9
<9.5-11> mathb10
<11-> mathb12
}{}
\DeclareSymbolFont{mathb}{U}{mathb}{m}{n}
\DeclareFontSubstitution{U}{mathb}{m}{n}

\DeclareMathSymbol{\test}{3}{mathb}{"D8}

\begin{document}

\PrintMathFonts

$\test$

\PrintMathFonts
\end{document}


You can not load a partial font so the answer to the question in the title is that it can not be done, to access a glyph you have to load the full font.

However, the implied question in the code (and in your related parallel question) is not to avoid loading a font but to keep within the classic tex limit of 16 font families in any given math expression.

When viewed from the position of using up \fam slots the code you show is fairly minimal, it only uses one slot (mathb) which is the least you can do if adding a new math symbol font.

The alternatives are to declare a math alphabet rather than a math symbol font, math alphabets only use a slot if they are actually used not when they are declared so you can declare more than 16 math alphabets as long as you do not use them all.

Or you can (at some cost to the macro complexity and loss of control over the positioning of subscripts and superscripts) use a text font rather than a math font.

So in short "without loading several fonts?" seems to be a misunderstanding. The code you show only uses one math family not several, and that is the count that matters, not that it uses several fonts for different sizes.

• Thanks a lot for the clarification! This post seems to do the job. This will also allow providing a way to not impose one font to the user of the package. – projetmbc Mar 3 at 19:46
• @projetmbc perhaps but you have given no example that suggests that you can do that in your case. As I said in this answer a math alphabet as in teh post you reference only uses a slot if used, but math alphabets are for things like \mathfrak{ABC} accessed via abc ... letters, not by named symbols accessed by character position like your definition of \test so that is a completely different situation. – David Carlisle Mar 3 at 20:01