2

I have a weird problem Whenever I use the caption package with beamer class on Mac OS (Windows works fine), Tables labels are changed to Figures (only started happening recently) .. I wonder what could be the problem.

See preamble of my latex presentation:

\documentclass[english,usenames,dvipsnames]{beamer}
\usepackage{mathptmx}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{amssymb}

\makeatletter

\providecommand{\tabularnewline}{\\}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
% this default might be overridden by plain title style
\newcommand\makebeamertitle{\frame{\maketitle}}%
% (ERT) argument for the TOC
\AtBeginDocument{%
  \let\origtableofcontents=\tableofcontents
  \def\tableofcontents{\@ifnextchar[{\origtableofcontents}{\gobbletableofcontents}}
  \def\gobbletableofcontents#1{\origtableofcontents}
}
\numberwithin{equation}{section}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
%\usetheme{Warsaw}
% or ...
%\usetheme{Madrid}
\usetheme{CambridgeUS}
\usecolortheme{beaver}
%\renewcommand{\tabcolsep}{0.2 cm}
\usepackage{textpos}
\usepackage{enumerate}
%\usepackage[shortlabels]{enumitem}
%\usepackage{anyfontsize}
\usepackage{multicol}
\usepackage{setspace}
\usepackage{latexsym}
%\setbeamertemplate{caption label separator}{: } 
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{algorithm, algorithmic}
\renewcommand\thesubsection{\Alph{subsection}}
%\usepackage{algpseudocode}
\usepackage{graphicx}
%\usepackage{longtable}
\usepackage{bm}
\usepackage{wrapfig}
\usepackage{ragged2e}
\usepackage{lipsum}
\usepackage{fancybox}
\usepackage{listings}
\usepackage{cite}
\usepackage{color}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{tikz-network}

\usepackage{caption}


\usepackage{diagbox}
\setbeamercovered{transparent}
% or whatever (possibly just delete it)
\usepackage{multirow}
%\usepackage{algorithm2e}
%\usepackage{algorithmicx}
%\usepackage{float}
\setbeamertemplate{caption}[numbered]
\algsetup{linenosize=\small}


\renewcommand{\makebeamertitle}
{
\begingroup
\setbeamertemplate{footline}{}
\setbeamertemplate{navigation symbols}{}
\frame{\titlepage}
\endgroup
}

\makeatother

\begin{document}
\title[]{Example}
\author[latex forum]{example\and \\ \bigskip{}
}
\institute[]{%\includegraphics[scale=0.07]{institution-logo-filename} \\\\
}
\date[October 2019]{}

\makebeamertitle

%\beamerdefaultoverlayspecification{<+->}

\addtocounter{framenumber}{-1}



\section{Introduction}
\begin{frame}{CIs Disruptions Examples}

\begin{table}
\begin{tabular*}{12cm}{@{\extracolsep{\fill}}ll}
\toprule 
Date & \multicolumn{1}{c}{Disruption}\tabularnewline
\midrule
\midrule 
{\scriptsize{}November 1965} & {\scriptsize{}Blackout in ten states in the northeastern US affected
30 million people.}\tabularnewline
\midrule
\midrule 
{\scriptsize{}July 1977} & {\scriptsize{}In New York’s suburbs,10 million people to lose power
for over 24 h.}\tabularnewline
\midrule
\midrule 
{\scriptsize{}December 1978} & {\scriptsize{}Blackout in part of France due to voltage collapse.}\tabularnewline
\midrule
\midrule 
{\scriptsize{}January 1981} & {\scriptsize{}1.5 million customers in Idaho, Utah, and Wyoming were
affected for 7 h.}\tabularnewline
\midrule
\midrule 
{\scriptsize{}March 1982} & {\scriptsize{}Over 900 000 lost power for 1.5 h due to high-voltage
line failure in Oregon.}\tabularnewline
\midrule
\midrule 
{\scriptsize{}December 1994} & {\scriptsize{}2 million customers from Arizona to Washington State
lost power.}\tabularnewline
\midrule
\midrule 
{\scriptsize{}July 1996} & {\scriptsize{}Blackouts for 2 million customers in 14 states for approximately
6h.}\tabularnewline
\midrule 
{\scriptsize{}August 2003} & {\scriptsize{}Northeastern United States and Canada cascading outages}\tabularnewline
\bottomrule
\end{tabular*}

\caption{\label{tab:Disruptions-Examples}Power Disruptions Examples}
\end{table}
\end{frame}
%

\end{document}

Output

  • \@captype is figure from the very start, so somehow \table was clobbered. – John Kormylo Oct 18 at 14:37
  • I am not following .. on windows, the same latex file produces Table 1 instead of Figure 1 – Bassem Oct 18 at 14:43
  • As a quick fix, you can use \begin{table}\expandafter\def\csname @captype\endcsname{table}. – John Kormylo Oct 18 at 14:49
  • Actually, \begin{table}\relax will fix it. Is Beamer's version of \table expecting an argument? – John Kormylo Oct 18 at 14:54
  • BTW, you table of contents mod is backwards: \gobbletableofcontents should come first, assuming you want of remove the optional argument. – John Kormylo Oct 18 at 15:04
2

This looks like a clear bug. The code sets the code for the table to figure:

\@ifclassloaded{beamer}{%
  \caption@InfoNoLine{beamer document class}%
  \let\caption@ORI@figure\figure
  \def\figure{\caption@settype{figure}\caption@ORI@figure}
  \let\caption@ORI@table\figure %<------------------------HERE
  \def\table{\caption@settype{table}\caption@ORI@table}
}{}

Report it to the maintainer.

0

Beamer's version of table must be getting replaced by the caption package. Simply restore it after caption is loaded using

\makeatletter
\renewenvironment{table}[1][]{%
  \def\@captype{table}%
  \par\nobreak\begin{center}\nobreak}
  {\par\nobreak\end{center}\nobreak}
\makeatother

Alternatively, one can save and restore table using:

\let\beamertable=\table
\let\beamerendtable=\endtable
\usepackage{caption}
\let\table=\beamertable
\let\endtable=\beamerendtable

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.