37

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".

3
  • 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. May 8, 2011 at 10:36
  • 3
    I thought that it would be more polite to say "thank you" explicitly...
    – strauberry
    May 8, 2011 at 10:53
  • 4
    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. May 8, 2011 at 11:07

3 Answers 3

46

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}

figures

1
  • 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, 2011 at 10:30
2

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.

1
  • 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, 2011 at 10:29
0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .