I have created the following frame in beamer:
\begin{frame}[t]{Adjacency Matrix}
\vspace{1em}
\only<1>{
\begin{block}{What is an adjacency matrix?}
\vspace{0.5em}
An adjacency matrix is a square matrix used to represent a finite graph.
\end{block}
\vspace{0.5em}
For a graph with $\mathbold{\abs{V}}$ vertices, an adjacency matrix is a $\mathbold{\abs{V} \times \abs{V}}$ matrix.
\\\vspace{1em}
If the edge between vertex $\mathbold{i}$ and vertex $\mathbold{j}$ is denoted by $\mathbold{V_{i,j}}$ then there are two possibilities.
}
% ........
\end{frame}
Now inside this frame, I want several slides. For that I wrote the following code:
\setbeamertemplate{itemize items}[ball]
\begin{enumerate}
\only<2>{
\item Unweighted Graph
\vspace{1em}
\begin{itemize}
\item Matrix of 0s and 1s where in row $\mathbold{i}$ and column $\mathbold{j}$ is $1$ iff the edge $\mathbold{(i,j)}$ is in the graph
\end{itemize}
\[ \Scale[1]{
V_{i,j} = \begin{cases}
1 & if ~ edge(i,j) ~ exists \\
0 & otherwise
\end{cases}
}
\]
}
\only<3>{
\item Weighted Graph
\begin{itemize}
\item Edge weight is placed in $\mathbold{V_{i,j}}$ entry if there is an edge and a special value (perhaps \textit{null} to indicate absence of an edge.
\end{itemize}
}
\end{enumerate}
I want the first item (Unweighted graph,enumerated 1) to show on slide 2 and the second item (Weighted graph,enumerated 2) to show on slide 3. But when I run this, on sharelatex, it shows the following error:
main.tex, line 106
LaTeX Error: Something's wrong--perhaps a missing \item.
There are no entries found in a list you have created. Make sure you label list entries using the \item command, and that you have not used a list inside a table.
Learn more Was this hint helpful? Yes / No
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.106 \end{frame}
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
Currently, it's looking like this:
Both unweighted and weighted graph are enumerated 1.
What am I doing wrong?
The full code:
\documentclass[12pt]{beamer}
\usetheme{metropolis}
\usecolortheme{spruce}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{fixmath}
\usepackage{graphicx}
\newcommand*{\Scale}[2][4]{\scalebox{#1}{$#2$}}%
\newcommand*{\Resize}[2]{\resizebox{#1}{!}{$#2$}}%
\DeclarePairedDelimiter\abs{\lvert}{\rvert}%
\DeclarePairedDelimiter\norm{\lVert}{\rVert}%
% Swap the definition of \abs* and \norm*, so that \abs
% and \norm resizes the size of the brackets, and the
% starred version does not.
\makeatletter
\let\oldabs\abs
\def\abs{\@ifstar{\oldabs}{\oldabs*}}
%
\let\oldnorm\norm
\def\norm{\@ifstar{\oldnorm}{\oldnorm*}}
\makeatother
\title[About Beamer]{Graph Representation Techniques}
\author[Author A and Author B]{Tanjim Bin Faruk (1505082) \\ Tanjim Munir (1505083) }
\institute{}
\date{\today}
\setbeamertemplate{title page}{
\begin{minipage}[b][\paperheight]{\textwidth}
\ifx\inserttitlegraphic\@empty\else\usebeamertemplate*{title graphic}\fi
\vfill%
\centering % NEW
\ifx\inserttitle\@empty\else\usebeamertemplate*{title}\fi
\ifx\insertsubtitle\@empty\else\usebeamertemplate*{subtitle}\fi
\usebeamertemplate*{title separator}
\vspace*{10mm}
\ifx\beamer@shortauthor\@empty\else\usebeamertemplate*{author}\fi
\vspace*{20mm} % NEW
\ifx\insertdate\@empty\else\usebeamertemplate*{date}\fi
\ifx\insertinstitute\@empty\else\usebeamertemplate*{institute}\fi
\vfill
\vspace*{1mm}
\end{minipage}
}
\setbeamertemplate{title}{
% \raggedright%
\centering
\linespread{1.0}%
\inserttitle%
\par%
\vspace*{0.5em}
}
\begin{document}
\metroset{block = fill}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}[t]{Adjacency Matrix}
\vspace{1em}
\only<1>{
\begin{block}{What is an adjacency matrix?}
\vspace{0.5em}
An adjacency matrix is a square matrix used to represent a finite graph.
\end{block}
\vspace{0.5em}
For a graph with $\mathbold{\abs{V}}$ vertices, an adjacency matrix is a $\mathbold{\abs{V} \times \abs{V}}$ matrix.
\\\vspace{1em}
If the edge between vertex $\mathbold{i}$ and vertex $\mathbold{j}$ is denoted by $\mathbold{V_{i,j}}$ then there are two possibilities.
}
\setbeamertemplate{itemize items}[ball]
\begin{enumerate}
\only<2>{
\item Unweighted Graph
\vspace{1em}
\begin{itemize}
\item Matrix of 0s and 1s where in row $\mathbold{i}$ and column $\mathbold{j}$ is $1$ iff the edge $\mathbold{(i,j)}$ is in the graph
\end{itemize}
\[ \Scale[1]{
V_{i,j} = \begin{cases}
1 & if ~ edge(i,j) ~ exists \\
0 & otherwise
\end{cases}
}
\]
}
\only<3>{
\item Weighted Graph
\begin{itemize}
\item Edge weight is placed in $\mathbold{V_{i,j}}$ entry if there is an edge and a special value (perhaps \textit{null} to indicate absence of an edge.
\end{itemize}
}
\end{enumerate}
\end{frame}
\end{document}