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.

Could anybody tell me why the following beamer document does not compile?

\documentclass{beamer}

\DeclareMathAlphabet{\mathbb}{U}{msb}{m}{n}
\let\mathbb\undefined
\DeclareMathAlphabet{\mathbb}{U}{msb}{m}{n}

\begin{document}
\begin{frame}
$\mathbb{Q}$
\pause
\begin{itemize}
 \item Test
\end{itemize}
\end{frame}
\end{document}

The strange thing is that the code compiles when I remove either one of the following:

  1. the first \DeclareMathAlphabet,
  2. \let\mathbb\undefined,
  3. $\mathbb{Q}$
  4. \pause,
  5. the itemize environment.

Of course, the first two lines in this document are superfluous, but I would like to know what is going wrong.

I am using beamer in version 3.10 with TeXLive 2011.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

The error has surely to do with beamer's internal working when trying to split material for the overlays. I've not followed the error, but I have some suspects:

  1. the \let\mathbb\undefined makes LaTeX follow a different branch in a conditional than when it finds the command defined;

  2. math alphabets are evaluated only when needed, because of the strong limitation to 16 math families (this explains why omitting \mathbb{Q} doesn't trigger the error);

  3. the error doesn't show without \pause because there's no "delayed expansion" (similar when TeX is writing out an auxiliary file).

You get the same error with

\documentclass[a4paper]{article}
\DeclareMathAlphabet{\mathbb}{U}{msb}{m}{n}
\let\mathbb\undefined
\DeclareMathAlphabet{\mathbb}{U}{msb}{m}{n}
\begin{document}
\tableofcontents
\section{A $\mathbb{Q}$}
\end{document}

but not at the first run: only at the second, when the .toc file is read in, the error shows.

Running the second example twice and skipping past errors with return, the

! LaTeX Error: Too many math alphabets used in version normal.

error message will show. This means that LaTeX is chasing its tail defining over and over again the same math alphabet. It does not happen if the \let\mathbb\undefined is omitted because it's legal to reassign a math alphabet selection command. When it's inserted, the system is in an unstable state, because \mathbb has no meaning, while \csname mathbb \endcsname has the old meaning (this has to do with "command robusting"). In the code for \DeclareMathAlphabet there's a conditional which depends on the first one being defined or not. If it's not, the second one is appended to the list of math alphabets to initialize, and I believe it's here that things go wrong: LaTeX finds the same command twice in the list \mv@normal that expands to

\getanddefine@fonts \symoperators \OT1/cmr/m/n
\getanddefine@fonts \symletters \OML/cmm/m/it
\getanddefine@fonts \symsymbols \OMS/cmsy/m/n
\getanddefine@fonts \symlargesymbols \OMX/cmex/m/n
\install@mathalphabet \mathbf  {\select@group \mathbf  \M@OT1 \OT1/cmr/bx/n }
\install@mathalphabet \mathsf  {\select@group \mathsf  \M@OT1 \OT1/cmss/m/n }
\install@mathalphabet \mathit  {\select@group \mathit  \M@OT1 \OT1/cmr/m/it }
\install@mathalphabet \mathtt  {\select@group \mathtt  \M@OT1 \OT1/cmtt/m/n }
\install@mathalphabet \mathbb  {\select@group \mathbb  \M@U \U/msb/m/n }
\install@mathalphabet \mathbb  {\select@group \mathbb  \M@U \U/msb/m/n }

(end-of-lines have been added for clarity). It's clearly visible that \mathbb  (with a space in the name) appears twice. I don't understand precisely why this becomes a problem when typesetting the table of contents (or storing in memory the frame with \pause in beamer), but it obviously has to do with this duplication.

It's always risky to say \let\xyz\undefined when \xyz is defined by \DeclareRobustCommand or another command that performs a similar task and then redefining \xyz.

share|improve this answer
    
Thanks. I would be glad if you could explain further why the first three commands after \documentclass are not equivalent to a single call to \DeclareMathAlphabet? –  Michael Ummels Sep 7 '11 at 8:38
    
@Michael Here is further analysis. –  egreg Sep 7 '11 at 9:11
    
Thanks! The problem is that e.g. the eufrak package uses \newcommand to define \mathfrak, and then \DeclareMathAlphabet gives an error when \mathfrak is not set to undefined before. –  Michael Ummels Sep 8 '11 at 8:58
1  
Yes: \DeclareMathAlphabet can know whether the command is already defined as a math alphabet choice command; otherwise it raises the error, since it assumes you are trying to redefine a command, while reassigning a math alphabet is quite common. Actually eufrak is kind of obsolete, since amsfonts is richer; however it seems a bad design decision to use \newcommand instead of \DeclareMathAlphabet. –  egreg Sep 8 '11 at 23:37

Why use \DeclareMathAlphabet instead of \usepackage{amssymb}? The following appears to work fine, as far as I can tell:

\documentclass{beamer}
\usepackage{lmodern} % To avoid ``LaTeX Font Warning: Font shape `OT1/cmss/m/n' in
                     % size <4> not available'' warnings
\usepackage{amssymb}

\begin{document}
\begin{frame}
$\mathbb{Q}$
\pause
\begin{itemize}
 \item Test
\end{itemize}
\end{frame}
\end{document}
share|improve this answer
    
As I said, the error also does not occur if I remove the first \DeclareMathAlphabet statement. I just want to know why there is an error. –  Michael Ummels Sep 7 '11 at 5:19
    
Right, I was just wondering why you went that route at all -- the amsmath and related documentation normally never mentions it at all, and just says to use amssymb, which appears to be either inherently more robust than \DeclareMathAlphabet, or beamer takes extra effort to accommodate it. –  Mike Renfro Sep 7 '11 at 11:27
    
The error occurred for me because I included two packages that both redefine one of the alphabets. BTW, if I look into amsfonts.sty (which is included by amssymb.sty), it seems it just uses \DeclareMathAlphabet and the related \DeclareSymbolFontAlphabet itself to set up the math alphabets. –  Michael Ummels Sep 8 '11 at 8:50
    
I thought it could be something like that, but wanted to make sure. I suppose the packages could check if the proper math alphabets were already set, or else use a different command to clear or redefine the math alphabet, similar to what @egreg mentioned earlier. –  Mike Renfro Sep 8 '11 at 11:50

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.