I'm trying to run Beamer to get a listing in a presentation. I'm getting a mysterious error message that looks like:
! Missing number, treated as zero.
<to be read again>
\let
l.221 \end{frame}
? H
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
Part of my problem is that \let is not in my code, this must be the expansion of a macro. My immediate question is "How can I get TeX to give me information about what macros it was expanding when it encountered the error?" That might give me a clue about what to do next.
More context: I'm trying to use an algorithm listing of json objects in Beamer.
I have the following defined in my header:
\usepackage{algorithmicx}
\usepackage{algorithm}
\floatname{algorithm}{Example}
%--------------------------------------------
%JSON listing mode, from
% https://tex.stackexchange.com/questions/83085/how-to-improve-listings-display-of-json-files#83100
\usepackage{listings}
\usepackage{xcolor}
\colorlet{punct}{red!60!black}
\definecolor{background}{HTML}{EEEEEE}
\definecolor{delim}{RGB}{20,105,176}
\colorlet{numb}{magenta!60!black}
\lstdefinelanguage{json}{
basicstyle=\normalfont\ttfamily,
numbers=left,
numberstyle=\scriptsize,
stepnumber=1,
numbersep=8pt,
showstringspaces=false,
breaklines=true,
frame=lines,
backgroundcolor=\color{background},
literate=
*{0}{{{\color{numb}0}}}{1}
{1}{{{\color{numb}1}}}{1}
{2}{{{\color{numb}2}}}{1}
{3}{{{\color{numb}3}}}{1}
{4}{{{\color{numb}4}}}{1}
{5}{{{\color{numb}5}}}{1}
{6}{{{\color{numb}6}}}{1}
{7}{{{\color{numb}7}}}{1}
{8}{{{\color{numb}8}}}{1}
{9}{{{\color{numb}9}}}{1}
{:}{{{\color{punct}{:}}}}{1}
{,}{{{\color{punct}{,}}}}{1}
{\{}{{{\color{delim}{\{}}}}{1}
{\}}{{{\color{delim}{\}}}}}{1}
{[}{{{\color{delim}{[}}}}{1}
{]}{{{\color{delim}{]}}}}{1},
}
The code for the frame in the Beamer file is:
\begin{frame}{Proc4 Messages}
\begin{columns}
\begin{column}{0.5\textwidth}
\begin{algorithm}
\begin{lstlisting}[language=json]
{
app:"ecd://coe.fsu.edu/EPLS/AssessmentName",
uid:"Student/User ID",
timestamp:"Time at which event occurred",
verb:"Action Keyword",
object:"Object Keyword",
data:{
field1:"Value",
field2:["list","of","values"],
field3:{part1:"complex",part2:"object"}
}
}
\end{lstlisting}
\end{algorithm}
\end{column}
\begin{column}{0.5\textwidth}
\begin{itemize}
\item Application header defines vocabulary used in other
fields.
\item ...
\item Data field can hold any number/kind of object.
\end{itemize}
\end{column}
\end{columns}
\end{frame}
The same listing runs fine in another document that uses article rather than beamer style, and the rest of the frame is pretty standard.
lstlistingshould not be placed inside analgorithmif thatalgorithmis a float, sincelstlistingprovides its own floating behaviour. – Werner Oct 22 '18 at 23:33\begin{frame}[fragile]\frametitle{Proc4 Messages}is the right way. I can't see the need for thealgorithmenvironment. – egreg Oct 22 '18 at 23:38\usepackage{xcolor}with beamer and there is not enough room on a slide to fit in two columns of0.5\textwidthbecause there is some space between the columns. Either make your columns a bit smaller or use\begin{columns}[onlytextwidth]– samcarter_is_at_topanswers.xyz Oct 22 '18 at 23:40\errorcontextlines5on a line in the preamble. – Oct 23 '18 at 06:46