Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This is a follow up question to this rather vague one. The problem is trying to work out where my 16 math alphabets are going. In using egreg's answer to the previous question I have diagnosed something. So check out this madness:

\documentclass{article}
\usepackage{kpfonts}

\newcommand{\PrintMathFonts}[1]{%
  \count255=0
  \loop\ifnum\count255<16
    \typeout{#1 (\the\count255: \fontname\textfont\count255)}
    \advance\count255 by 1
 \repeat}
\usepackage{siunitx}

\begin{document}
\PrintMathFonts{Initial}
\SI{10}{\celsius}
$X$
\PrintMathFonts{Final}
X
\end{document}

This prints out what math alphabets have been allocated at various points. Here's the relevant part of the log file:

Initial (0: jkpmn7t)
Initial (1: jkpmi)
Initial (2: jkpsy)
Initial (3: jkpex)
Initial (4: jkpmia)
Initial (5: jkpsya)
Initial (6: jkpsyb)
Initial (7: jkpsyc)
Initial (8: jkpexa)
Initial (9: jkpssmn7t)
Initial (10: jkpttmn7t)
Initial (11: nullfont)
Initial (12: nullfont)
Initial (13: nullfont)
Initial (14: nullfont)
Initial (15: nullfont)
Final (0: jkpmn7t)
Final (1: jkpmi)
Final (2: jkpsy)
Final (3: jkpex)
Final (4: jkpmia)
Final (5: jkpsya)
Final (6: jkpsyb)
Final (7: jkpsyc)
Final (8: jkpexa)
Final (9: jkpssmn7t)
Final (10: jkpttmn7t)
Final (11: jkpmn7t)
Final (12: nullfont)
Final (13: nullfont)
Final (14: nullfont)
Final (15: nullfont)

So, before I have typed anything at all TWELVE of my sixteen fonts are already used. siunitx appears to cause the math alphabets to be used before anything is written. OK. That's fine, I'll leave that aside for now. What's doubly weird is that once I've used \SI to typeset so units, another alphabet is used up (position 11). What's odd about this is that it's the same font as position 0. Why is this? Isn't this a waste? Can I don something about it?

Using standard computer modern means only 6 alphabets are used up at Initial and that's the same as at Final. Using fouriernc seems to cause the same problem (duplicate font) as with kpfonts. However, fewer fonts are used up.

share|improve this question

2 Answers 2

up vote 6 down vote accepted

The packages kpfonts, fourier and fouriernc all say

\DeclareMathAlphabet{\mathrm}{<enc>}{<family>}{<weight>}{<shape>}

instead of the correct

\DeclareSymbolFontAlphabet{\mathrm}{operators}

that's recommended by fntguide.pdf; this causes LaTeX to load an extra font when something with \mathrm is typeset (for example a unit with \SI). To avoid this, issue the latter command after loading the font package.

share|improve this answer
    
after loading the font package, and before loading siunitx right? –  Seamus Jan 12 '12 at 16:45
2  
@Seamus Before or after siunitx should be irrelevant. –  egreg Jan 12 '12 at 16:51

I can explain the siunitx part, if not the entire situation. In order to be able to tell which math font is in use, at the start of the document there is a need to force some math typesetting. This is done using more or less

\setbox\tempbox=\hbox{\ensuremath{\mathsf{\global\chardef\siunitxmathsf=\fam}}}
\setbox\tempbox=\hbox{\ensuremath{\mathtt{\global\chardef\siunitxmathtt=\fam}}}

which records the family number for the sanserif and monospaced math fonts for later use.

The second thing to know is that siunitx uses \mathrm to typet upright material in math (as standard). If you try

\documentclass{article}
\usepackage{kpfonts}

\newcommand{\PrintMathFonts}[1]{%
  \count255=0
  \loop\ifnum\count255<16
    \typeout{#1 (\the\count255: \fontname\textfont\count255)}
    \advance\count255 by 1
 \repeat}

\begin{document}
\PrintMathFonts{Initial}
$\mathrm{a}$
\PrintMathFonts{Final}
\end{document}

you will see that this also uses an 'extra' font. This does not happen with other math font packages, and so presumably is a bug/'feature' of kpfonts.

share|improve this answer
    
What about the problem of loading the same font twice? That happened with fouriernc as well as kpfonts though not with computer modern. –  Seamus Jan 12 '12 at 14:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.