Graphics, Figures & TablesBeamer - subfig cancels captions numbering?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
User avatar
zgung
Posts: 2
Joined: Mon Jun 06, 2011 5:20 pm

Beamer - subfig cancels captions numbering?

Post by zgung »

I am using beamer class for presentation and subfig package somehow cancels figure numbering. The next code shows that when you insert the /usepackage{subfig} command, figures don't have numbers.

Code: Select all

\documentclass[xcolor=dvipsnames, compress, 9pt]{beamer} 
\usepackage{pgffor}
\usepackage{subfig}
\setbeamertemplate{caption}[numbered] 

\begin{document} 
\foreach \xx in {0,1}{% 
     \begin{frame} 
       \begin{figure} 
         \includegraphics[width=5cm]{ball-\xx} 
         \caption{} 
        \end{figure} 
     \end{frame}} 
\end{document} 
Anyone can help me with this?
Last edited by zgung on Mon Jun 06, 2011 9:08 pm, edited 3 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Beamer - subfig cancels captions numbering?

Post by sommerfee »

The subfig package loads the caption package and the caption package has a (documented) drawback when used with the beamer document class.

From the caption package documentation, section 5.3 "beamer":
Furthermore the beamer classes offer different caption templates which can be chosen with \setbeamertemplate{caption}[<template>]. Since the caption package replaces this caption template mechanism, \defbeamertemplate*{caption}{<template code>} and \setbeamertemplate{caption}[<template>] will have no effect when the caption package is used.
So either don't let the subfig package load the caption package, or replace

Code: Select all

\setbeamertemplate{caption}[numbered]
with

Code: Select all

\captionsetup{labelformat=simple}
User avatar
zgung
Posts: 2
Joined: Mon Jun 06, 2011 5:20 pm

Re: Beamer - subfig cancel captions numbering?

Post by zgung »

Works great,)

Thanks a lot
razkgb
Posts: 1
Joined: Tue Sep 20, 2011 8:02 pm

Re: Beamer - subfig cancels captions numbering?

Post by razkgb »

\setbeamertemplate{caption}[numbered]
\usepackage[caption=false]{subfig}

You can then use your \caption as usual.
Post Reply