1

I am having some problems with my recent Beamer presentation, namely with equations.

I would like to typeset the phrase $$\sum_{i=1}^{n}i=\frac{n(n+1)}{2}$$ in a typewriter font inside an equation, to show the syntax of LaTeX equations for a presentation that I am making.

However, I am getting vague errors when I compile the following MWE using XeLaTeX:

\documentclass[14pt]{beamer}
\usetheme{metropolis}

\usepackage{amsmath, amstext}

\begin{document}
  \begin{frame}[fragile]{Frame}
    \begin{equation*}
      \mathtt{\$\$\\sum\_\{i=1\}\;\widehat{}\;\{n\}i=\\frac\{n(n+1)\}\{2\}\$\$}
    \end{equation*}
  \end{frame}
\end{document}
! LaTeX Error: There's no line here to end.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.3 ...idehat{}\;\{n\}i=\\frac\{n(n+1)\}\{2\}\$\$}

?

I also tried the verbatim environment, which works when replacing \mathtt{...} with \verb|$$\sum_{i=1}^{n} i = \frac{n(n+1)}{2}$$|, but fails when I attempt to animate it:

\documentclass[14pt]{beamer}
\usetheme{metropolis}

\usepackage{amsmath, amstext}

\begin{document}
  \begin{frame}[fragile]{Frame}
    \onslide<+->{
    \begin{equation*}
      \verb|$$\sum_{i=1}^{n}i=\frac{n(n+1)}{2}$$|
    \end{equation*}}
  \end{frame}
\end{document}
! Missing $ inserted.
<inserted text>
                $
l.5     \end{equation*}}

?

Any help would be much appreciated!

1 Answers1

1

The second part of my question can be solved by removing the compound brackets after \onslide<+->:

\documentclass[14pt]{beamer}
\usetheme{metropolis}

\usepackage{amsmath, amstext}

\begin{document}
  \begin{frame}[fragile]{Frame}
    \onslide<+->
    \begin{equation*}
      \verb|$$\sum_{i=1}^{n}i=\frac{n(n+1)}{2}$$|
    \end{equation*}
  \end{frame}
\end{document}