4

I wrote some equation in a table and the frame of the slide has disappeared.

These are the packages I use:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\mode<presentation> {

\usetheme{Madrid}

}

\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage{amssymb}
\usepackage{blindtext}
\usepackage{amsmath}
\usepackage{csquotes}
\usepackage{tikz}
\usepgflibrary{arrows}
\usepackage{amscd}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}




\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage{amssymb}
\usepackage{blindtext}
\usepackage{amsmath}
\usepackage{csquotes}
\usepackage{tikz}
\usepgflibrary{arrows}
\usepackage{amscd}

This is how it looks like:

enter image description here

This is the code

\begin{frame}{Analytical forms}
    
\centering
\begin{table}
 
  \begin{tabular}{l|c}

Metric & Analytical form \\
\hline
Accuracy &   \begin{math}\frac { \sum_{n=1}^{c}  \frac{tp + tn}{tp + fp + tn + fn}}{c} \end{math}  \vspace{\baselineskip}\\ 
\hline 
 Precision &  \begin{math} \frac { \sum_{n=1}^{c}\frac{tp }{tp + fp}} {c} \end{math} \\ 
 \hline
 Recall &  \begin{math} \frac { \sum_{n=1}^{c}\frac{tp }{tp + fn} }{c} \end{math}\\
  \hline
 F1 score &  (1+\beta^2)\begin{math} \frac{AP.AR }{(\beta^2.AP) + AR}\end{math}
\end{tabular}
\caption{\label{tab:widgets}  Analytical form for each evaluation metric.}
\end{table}

\end{frame}
%------------------------------------------------
2
  • The red number you didn't show means that you have errors. You have to fix the errors before you can worry about the output.
    – Teepeemm
    Jan 6 at 17:12
  • (Your example gives me 20 errors on Overleaf, but there's really only one and it's on the F1 line.)
    – Teepeemm
    Jan 6 at 17:22

2 Answers 2

4

As @samcarter has already pointed out in this answer, the term \beta^2 has to occur in math mode.

At any rate, my main suggestions are to streamline and simplify the "look" of the table -- in part by avoiding "multi-storey" \frac expressions -- and to improve the readability of the math material by employing display-style math mode in the second column. In addition, since beamer doesn't "do" floats such as table and figure environments, you might as well get rid of the table machinery and stick the table's caption -- "Analytical form of each evaluation metric" -- into the frame title.

enter image description here

\documentclass{beamer}
%%\usepackage[utf8]{inputenc} % that's the default nowadays
\mode<presentation> { \usetheme{Madrid} }

\usepackage{array} % nmw
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage{amssymb}
\usepackage{blindtext}
\usepackage{amsmath}
\usepackage{csquotes}
\usepackage{tikz}
\usepgflibrary{arrows}
%\usepackage{amscd} % loaded automatically by 'amsmath' packagr
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}

\begin{document}

\begin{frame}{Analytical form of each evaluation metric}
    
\centering

\begin{tabular}{@{}l >{$\displaystyle}l<{$} @{}}

Metric    & \text{Analytical form} \\
\midrule
Accuracy  &   \frac{1}{c} \biggl( \sum_{n=1}^{c}  \frac{tp + tn}{tp + fp + tn + fn} \biggr) \\ 
\addlinespace
Precision &   \frac{1}{c} \biggl( \sum_{n=1}^{c}\frac{tp }{tp + fp} \biggr)  \\ 
\addlinespace
Recall    &   \frac{1}{c} \biggl( \sum_{n=1}^{c}\frac{tp }{tp + fn} \biggr) \\
\addlinespace
F1 score  &  (1+\beta^2) \frac{AP \cdot AR }{\beta^2 \cdot AP + AR}
\end{tabular}

\end{frame}

\end{document}
1
  • thank you so much
    – kjnk
    Jan 6 at 17:50
4

The main problem is that (1+\beta^2) needs to be in math mode.

Some other comments about your code:

  • please don't load the same package multiple times

  • you don't need to load graphicx, amssymb or amsmath, beamer automatically loads them for you

  • if your tex distribution is reasonable up to date, you don't need \usepackage[utf8]{inputenc}. That's now the default


\documentclass{beamer}
%\usepackage[utf8]{inputenc}
\mode<presentation> {

\usetheme{Madrid}

}

%\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{tikz}
%\usepackage{amssymb}
\usepackage{blindtext}
%\usepackage{amsmath}
\usepackage{csquotes}
\usepackage{tikz}
\usepgflibrary{arrows}
\usepackage{amscd}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}




%\usepackage{graphicx}
%\usepackage{booktabs}
%\usepackage{tikz}
%\usepackage{amssymb}
%\usepackage{blindtext}
%\usepackage{amsmath}
%\usepackage{csquotes}
%\usepackage{tikz}
%\usepgflibrary{arrows}
%\usepackage{amscd}


\begin{document}

\begin{frame}{Analytical forms}
    
\centering
\begin{table}
 
  \begin{tabular}{l|c}

Metric & Analytical form \\
\hline
Accuracy &   \begin{math}\frac { \sum_{n=1}^{c}  \frac{tp + tn}{tp + fp + tn + fn}}{c} \end{math}  \vspace{\baselineskip}\\ 
\hline 
 Precision &  \begin{math} \frac { \sum_{n=1}^{c}\frac{tp }{tp + fp}} {c} \end{math} \\ 
 \hline
 Recall &  \begin{math} \frac { \sum_{n=1}^{c}\frac{tp }{tp + fn} }{c} \end{math}\\
  \hline
 F1 score &  \begin{math}  (1+\beta^2)\frac{AP \cdot AR }{(\beta^2 \cdot AP) + AR}\end{math}
\end{tabular}
\caption{\label{tab:widgets}  Analytical form for each evaluation metric.}
\end{table}

\end{frame}
%------------------------------------------------


\end{document}

enter image description here


To make your life easier, you could use the tabularray package for your table. This allow to automatically choose math mode for your right column and will give a bit better spacing:

\documentclass{beamer}
%\usepackage[utf8]{inputenc}
\mode<presentation> {

\usetheme{Madrid}

}

%\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{tikz}
%\usepackage{amssymb}
\usepackage{blindtext}
%\usepackage{amsmath}
\usepackage{csquotes}
\usepackage{tikz}
\usepgflibrary{arrows}
\usepackage{amscd}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}




%\usepackage{graphicx}
%\usepackage{booktabs}
%\usepackage{tikz}
%\usepackage{amssymb}
%\usepackage{blindtext}
%\usepackage{amsmath}
%\usepackage{csquotes}
%\usepackage{tikz}
%\usepgflibrary{arrows}
%\usepackage{amscd}


\usepackage{tabularray}

\begin{document}

\begin{frame}{Analytical forms}
    
\centering
\begin{table}
 
\begin{tblr}{
  colspec={l|c},
  column{2}={mode=dmath},
  cell{1}{2}={mode=text},
  vspan=even
}
Metric & Analytical form \\
\hline
Accuracy &  \frac { \sum_{n=1}^{c}  \frac{tp + tn}{tp + fp + tn + fn}}{c} \\ 
\hline 
 Precision &  \frac { \sum_{n=1}^{c}\frac{tp }{tp + fp}} {c} \\ 
 \hline
 Recall &   \frac { \sum_{n=1}^{c}\frac{tp }{tp + fn} }{c} \\
  \hline
 F1 score &   (1+\beta^2)\frac{AP \cdot AR }{(\beta^2 \cdot AP) + AR}\\
\end{tblr}
\caption{\label{tab:widgets}  Analytical form for each evaluation metric.}
\end{table}

\end{frame}
%------------------------------------------------


\end{document}

enter image description here

4

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .