# Remove colon in the caption of a figure if the caption is empty

One of my figures should not have a caption, only the normal numbering. To get this, I use this code:

\begin{wrapfigure}{l}{4cm}
\begin{center}
\includegraphics[width=3cm]{graphic.pdf}
\caption[Caption for the list of figures]{}
\label{fig:figureX}
\end{center}
\end{wrapfigure}

But now I get "Figure x.y:" as caption of my figure. How can I remove the ":", if the caption is empty? I found some solutions with renewcommand, but this changes the caption style in the whole document. I want to remove the colon only if the caption is empty. In any other case, it is good to have "Figure x.y: My Caption".

-
Welcome to tex.sx! It's not necessary to sign your questions (as there is already a box with your username below it) or to begin them with a greeting. – Martin Scharrer May 8 '11 at 10:36
I thought that it would be more polite to say "thank you" explicitly... – strauberry May 8 '11 at 10:53
yes, that's a reasonable assumption, but we're all "old friends" here (including you) so we save a bit of time, space, and life-keystrokes by taking the politeness as a given... Welcome. – Brent.Longborough May 8 '11 at 11:07

Just loading the caption package should solve this. It makes the colon a proper "separator", i.e. it only appears when there is something to separate.

\documentclass{article}
\usepackage{wrapfig}
\usepackage[demo]{graphicx}
\usepackage{caption}

\begin{document}
\begin{wrapfigure}{l}{4cm}
\begin{center}
\includegraphics[width=3cm]{graphic.pdf}
\caption[Caption for the list of figures]{}
\label{fig:figureX}
\end{center}
\end{wrapfigure}
\begin{wrapfigure}{l}{4cm}
\begin{center}
\includegraphics[width=3cm]{graphic.pdf}
\caption[Caption for the list of figures]{With caption}
\label{fig:figureX}
\end{center}
\end{wrapfigure}
\end{document}

-
Thank you very much for this answer, it is working perfectly! I'll accept the answer as soon as I am allowed to do so :-) (5 minutes rule...) – strauberry May 8 '11 at 10:30

found some solutions with renewcommand, but this changes the caption style in the whole document.

you can use the solution local (inside the wrapfigure environment)

You don't present a working minimal example. So we don't know any packages or the class in your document.

-
Thank you for the hint with the local option! I guessed that there is some trick, but I didn't think that it is that easy :-) Sorry for the lack of a minimal example! I had provided one if no answers were be given ;-) (Damn, conjuctive in the past... not easy ^^) – strauberry May 8 '11 at 10:29

In my document, I had \caption{\mycaption} in my figure. Unfortunately, package caption was unable to tell that my caption was empty when \mycaption was empty. It was only able to tell when I had \caption{}. So, I used the following solution:

\ifx&\mycaption&\caption{\mycaption}\else\caption{}\fi
-