[Tex/LaTex] Making Verbatim and Beamer play nice

beamerverbatim

I'm writing a beamer presentation on basic math type-setting in latex and I've been trying to use verbatim to display how math equations are typed. Using fragile this works, but I still get several annoying error messages every time I compile, so I'm never sure if I have an actual error or if beamer is just complaining about verbatim. The current offender would be:

\begin{verbatim}
\[
  X := \bigcup_{n \in \Mb N}\coprod_{\lambda \in \Lambda} 
       (X_\lambda \cap Y_\lambda ) \vee \Mb S^{n}.
\]
\end{verbatim}

I get error messages along the lines of:

LaTeX Font Warning: Font shape `OT1/cmss/m/n' in size <4> not available
(Font)              size <5> substituted on input line 11.

[1{/home/schlatjj/.texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./Math.toc)
[2] (./Math.vrb

LaTeX Font Warning: Font shape `OMS/cmss/m/n' undefined
(Font)              using `OMS/cmsy/m/n' instead
(Font)              for symbol `textbraceleft' on input line 6.

) [3] (./Math.vrb) [4] (./Math.vrb
! Undefined control sequence.
\test@single@character ...ken ->\def \math@format 
                                                  ##1{\mydollar ##1\mydollar...
l.10   \end{verbatim}

Are there any workarounds for this, something I can change in the code to make these error messages go away?

Best Answer

It seems that you use this hack of mine. (I told you that I wouldn't suggest using it, but I feel honored that you like it ...) However, as I wrote there, the hack is designed for the CM fonts only, so you shouldn't use it with the standard beamer fonts.

That said, I can't reproduce the error. I used the code Stefan Kottwitz had in the first version of his answer, and added my hack in the preamble. This compiles nicely.

Related Question