Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I understand how to put a caption on a figure, I'd do something like,

\begin{figure}[h]

...put figure here...

\label{figure1}\caption{this is a figure}

\end{figure}

and the caption reads,

Figure 1: this is a figure

which is all very well and good. However, I would dearly like my figure to only have the label,

Figure 1

without the caption. How would I do this?

(Basically, I have a figure that I want to reference, so I need it to have some label. It is perfectly fine without any caption, and adding one would detract from what is going on.)

share|improve this question
    
Shouldn't \caption[this is a figure]{} do the trick? –  bdecaf Apr 17 '12 at 12:34
    
possible duplicate of Remove colon in the caption of a figure if the caption is empty –  Jake Apr 17 '12 at 12:36
3  
In addition to the (good) answers about getting an "empty" caption, please observe that \label must go after \caption, otherwise you won't get a correct reference to the figure number. –  Stephan Lehmke Apr 17 '12 at 12:38
    
@StephanLehmke: I was wondering why the number was coming up wrong - I thought I had just accidentally merged some counters or something! –  user1729 Apr 17 '12 at 12:43
add comment

2 Answers

up vote 8 down vote accepted

First of all: First the caption than the label.

It depends on your loaded documentclass and packages. For example you can simple write:

\caption[this is a figure]{}

And the output is:

Figure 1:

The extra colon can be removed by changing the internal definition of the command \@makecaption. With no extra packages or a special class like memoir or KOMA you can use:

\documentclass[letterpaper, 10pt]{article}
\makeatletter
\def\mycaptsep{:\space}
\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \ifx\ignorespaces#2\relax%
     \let\mycaptsep\relax%
  \fi%
  \sbox\@tempboxa{#1\mycaptsep #2}%
  \ifdim \wd\@tempboxa >\hsize
    #1\mycaptsep #2\par
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}
\makeatother
\begin{document}
\begin{figure}[h]

...put figure here...
\caption{}
\label{figure1}
\end{figure}
\end{document}

If you are using the package caption it's more elegant. The package detects empty arguments of \caption:

\documentclass[letterpaper, 10pt]{article}
\usepackage{caption}
\begin{document}
\begin{figure}[h]

...put figure here...
\caption{}
\label{figure1}
\end{figure}
\end{document}

If you are using a KOMA class you must change the separator. This can be done global:

\documentclass[letterpaper, 10pt]{scrartcl}
\renewcommand*{\captionformat}{}
\begin{document}
\begin{figure}[h]

...put figure here...
\caption{}
\label{figure1}
\end{figure}
\end{document}
share|improve this answer
    
Could you perhaps give a brief explanation of what the code in your first example is doing? –  user1729 Apr 17 '12 at 12:50
1  
@user1729: I created a new command \mycaptsep to define a separator if the caption isn't empty. Then I redefined the internal command \@makecaption defined in the document class in this way that it uses the new command \mycaptsep. –  Marco Daniel Apr 17 '12 at 12:54
add comment

Try this.

\documentclass{article}
\usepackage[figurename=Figure]{caption}
\begin{document}
\begin{figure}
\caption{}
\end{figure}
\end{document}

The caption package is loaded to get rid of any unwanted punctuation that could appear after the figure number.

share|improve this answer
    
This is exactly what I was looking for. Thanks. –  user1729 Apr 17 '12 at 12:42
1  
Maybe add a correctly positioned \label. –  Stephan Lehmke Apr 17 '12 at 12:44
    
There's no need to use the figurename=Figure option; it's enough to load caption. –  Gonzalo Medina Apr 17 '12 at 13:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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