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!
$$...$$(Why is\[ … \]preferable to$$?) – samcarter_is_at_topanswers.xyz Mar 21 '19 at 20:01$$...$$, because the presentation is about Jekyll-based website where the equations are rendered using KaTeX, and the setup I am using requires this syntax. – Tomáš Sláma Mar 21 '19 at 20:06\\does not produce a backslash. – egreg Mar 21 '19 at 22:19