[Tex/LaTex] Error on table inside a beamer

beamertables

I'm preparing a presentation using the beamer class, and I need to put a tabular environment inside it and I always get the errors

Undefined control sequence \end{frame}

and

Missing number, treated as zero \end{frame}

The document is not compiling.

I'm kinda new to LaTeX and I keep all my packages from document to document, I forgot what are some for.
Do you have an idea what is happening?

\PassOptionsToPackage{table}{xcolor}
\documentclass[xcolor=dvipsnames]{beamer}

\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage[french]{babel}
\usepackage{xlop} %opérations de beau gosse
\hypersetup{pdfpagemode=FullScreen} %probablement fullscreen at launch
\graphicspath{{images/}}
\usepackage{graphicx}

\usetheme{Berkeley}
\definecolor{color1}{RGB}{0,165,50} %creer une couleur
\setbeamercolor{normal text}{bg=white,fg=black}
\usecolortheme[named=color1]{structure} %utiliser une couleur
\setbeamertemplate{navigation symbols}{} 

\theoremstyle{definition} %pour des boites a théorèmes
\newtheorem*{dfn}{Définition}       

\usepackage{multicol}
\usepackage{setspace}
\usepackage{hyperref}
\usepackage{lastpage}
\usepackage{textcomp}
\usepackage{rotating}


%\usepackage{colortbl}
\usepackage[table]{xcolor}

\addtobeamertemplate{footline}{\hfill\insertframenumber/\inserttotalframenumber\hspace{0.1cm}\null\vspace{0.05cm}} %numéro des diapos

\usepackage{setspace}


\begin{document}
\begin{frame}
\begin{figure}[H]
\doublespacing
\begin{center}
\begin{tabular}{cccc}

\hline
\textbf{Wear mechanisms} & \textbf{Applications} & \textbf{Deposited materials} & \textbf{Deposition processes}\\
\hline
Abrasive wear & Pump shafts & Cr-Co & HOVF, plasma, detonation\\
\hline
Adhesive wear & Pistons, brakes & Mo, Ni-Cr, Cu-Ni-In & Plasma, flame, HOVF\\
\hline
Contact wear & Aircraft leading edge & Tungsten carbide, Co & Detonation HVOF\\
\hline
Erosion & Power plant fan & Tungsten carbide, $\textnormal{Al}_{2}\textnormal{O}_{3}$, $\textnormal{Cr}_{2}\textnormal{O}_{3}$ & Detonation, HVOF\\
\hline

\end{tabular}
\caption{Examples of thermal sprayed coatings against wear}
\end{center}
\end{figure}
\end{frame}
\end{document}

Best Answer

As I told you, the problem with your code was command \doublespacing. Commenting it out, your code will compile without problems. You wanted it to "wider" table spacing. If this means a larger distance between tabular text and separation lines you have several alternatives. One of them consists in fixing \extrarowheight from array package. Next code (taken from "The LaTeX Companion, 2ed") shows how to use it and its effects on rows height.

\begin{tabular}{|>{\large}c|>{\large\bfseries}l|>{\itshape}c|}
\hline A & B & C\\\hline 100 & 10 & 1\\\hline
\end{tabular}

\setlength\extrarowheight{4pt}
\begin{tabular}{|>{\large}c|>{\large\bfseries}l|>{\itshape}c|}
\hline A & B & C\\\hline 100 & 10 & 1\\\hline
\end{tabular}

enter image description here

In any case I prefer to use booktabs package and its \top-\mid-\bottomrule commands. I think results are good enough without any other adjustments.

Next code shows an example typesetting your table inside a beamer frame. I've made some adjustments to fit all table in one frame.

  1. Used \small to reduce font size
  2. Used array package for >{decl} and center cell text
  3. Used p{column width} cell types
  4. Used booktabs package

The complete code is

\PassOptionsToPackage{table}{xcolor}
\documentclass[xcolor=dvipsnames]{beamer}

\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[french]{babel}

\usetheme{Berkeley}
\definecolor{color1}{RGB}{0,165,50} %creer une couleur
\setbeamercolor{normal text}{bg=white,fg=black}
\usecolortheme[named=color1]{structure} %utiliser une couleur
\setbeamertemplate{navigation symbols}{} 

%\usepackage{lastpage}
\usepackage{textcomp}
\usepackage{booktabs}
\usepackage{array}
%\usepackage[table]{xcolor}

\addtobeamertemplate{footline}{\hfill\insertframenumber/\inserttotalframenumber\hspace{0.1cm}\null\vspace{0.05cm}} %numéro des diapos

%\usepackage{setspace}


\begin{document}
\begin{frame}
\begin{figure}%[H]
\centering

{\small\begin{tabular}{%
    >{\centering\hspace{0pt}}p{.2\textwidth}
    >{\centering\hspace{0pt}}p{.2\textwidth}
    >{\centering\hspace{0pt}}p{.2\textwidth}
    >{\centering\hspace{0pt}}p{.2\textwidth}}

\toprule
\textbf{Wear mechanisms} & \textbf{Applications} & \textbf{Deposited materials} & \textbf{Deposition processes}\tabularnewline
\midrule
Abrasive wear & Pump shafts & Cr-Co & HOVF, plasma, detonation\tabularnewline
\midrule
Adhesive wear & Pistons, brakes & Mo, Ni-Cr, Cu-Ni-In & Plasma, flame, HOVF\tabularnewline
\midrule
Contact wear & Aircraft leading edge & Tungsten carbide, Co & Detonation HVOF\tabularnewline
\midrule
Erosion & Power plant fan & Tungsten carbide, $\textnormal{Al}_{2}\textnormal{O}_{3}$, $\textnormal{Cr}_{2}\textnormal{O}_{3}$ & Detonation, HVOF\tabularnewline
\bottomrule

\end{tabular}}
\caption{Examples of thermal sprayed coatings against wear}

\end{figure}
\end{frame}

\begin{frame}

\begin{tabular}{|>{\large}c|>{\large\bfseries}l|>{\itshape}c|}
\hline A & B & C\\\hline 100 & 10 & 1\\\hline
\end{tabular}

\setlength\extrarowheight{4pt}
\begin{tabular}{|>{\large}c|>{\large\bfseries}l|>{\itshape}c|}
\hline A & B & C\\\hline 100 & 10 & 1\\\hline
\end{tabular}

\end{frame}

\end{document}

The final result is

enter image description here

Related Question