10

I am using my figures and tables both in report documents, where I want them to have caption text, an in presentations made with Beamer, where I want them to not have a caption text. I am using the Caption package (2011/08/11) both for my report and presentations.

Is there a simple way to turn off the caption text when I use the figures and tables in my presentations?

myotis
  • 936
  • Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It is considered a lot better to put in some code that will compile, as it makes it a lot easier for us to copy it into our text editor and work with it, and see exactly what it is you are trying to do. – Stephan Lehmke Nov 28 '12 at 10:54
  • 2
    How about \DeclareCaptionFormat{empty}{}\captionsetup{format=empty}? – cgnieder Nov 28 '12 at 10:55
  • Thanks:) but when I put that string in the preamble I get this: ! Undefined control sequence. l.21 \DeclareCaptionFormat {empty}{}\captionsetup{format=empty} – myotis Nov 28 '12 at 11:03
  • 2
    They are provided by the caption package (which you said you're using) so you need to put it after \usepackage{caption} – cgnieder Nov 28 '12 at 11:07
  • It works fine !! (I forgot to put the \DeclareCaptionFormat string AFTER the \usepackage{caption} command . – myotis Nov 28 '12 at 11:12

2 Answers2

13

Since you're using the caption package already you can use its possibilites to define own caption formats to define one that outputs nothing by saying

\DeclareCaptionFormat{empty}{}

You can now use this format by setting it with \captionsetup:

\captionsetup{format=empty}

A complete example:

\documentclass{beamer}
\usepackage{caption}
\DeclareCaptionFormat{empty}{}
\captionsetup{format=empty}
\begin{document} 

\begin{frame}
\begin{figure}
 some figure
 \caption{some caption}
\end{figure}
\end{frame}

\end{document}

As noted by Axel Sommerfeldt in the comments it is probably a good idea also to set the skip above and below the caption to zero. Otherwise you might wonder where the vertical space below the figure comes from... For this just extend the caption setup:

\captionsetup{format=empty,aboveskip=0pt,belowskip=0pt}
cgnieder
  • 66,645
  • 2
    I would set the skips above and below the caption to 0pt additionally, i.e. \captionsetup{format=empty,aboveskip=0pt,belowskip=0pt} –  Nov 29 '12 at 09:10
  • @Axel Good point! – cgnieder Nov 29 '12 at 09:24
  • If the same document is producing the article and beamer versions you might want to put the caption formatting commands inside \mode<presentation>{...}. – Andrew Stacey Nov 29 '12 at 10:07
  • @Andrew true, but I thought that wouldn't be too hard to figure out if one already is using one document for both :) – cgnieder Nov 29 '12 at 10:24
4

(For reference, without any package.) Put this into your preamble:

\makeatletter
\def\@gobblebracket[#1]{}
\def\caption{\@ifnextchar[{\expandafter\@gobble\@gobblebracket}\@gobble}
\makeatother

or even simpler (credit to Andrew):

\renewcommand \caption [2][]{}
yo'
  • 51,322