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}
A preliminary remark: If a journal you're submitting an article to requires you to use the elsarticle
document class, it may be a poor idea to modify the caption style defined by the class. Your journal's style guidelines probably also state something to the effect that every float should have a (nonempty) caption, in which case some kind of separator (such as a colon) between the float's number and caption is generally needed.
Here's the definition of the \@makecaption
command contained in the file elsarticle.cls
\long\def\@makecaption#1#2{%
\vskip\abovecaptionskip\footnotesize
\sbox\@tempboxa{#1: #2}%
\ifdim \wd\@tempboxa >\hsize
#1: #2\par
\else
\global \@minipagefalse
\hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
\fi
\vskip\belowcaptionskip}
The two arguments of the \@makecaption
macro are [Float] <num>
and the caption's text, respectively. [Float] can be "Figure", "Table", or the name of any other floating environment recognized by LaTeX.
There are two ways to suppress the insertion of a colon following the float's name and number.
Method 1 : Remove the colon globally because the mandatory arguments (the stuff inside curly braces) of all \caption
commands will always be empty. To achieve this, you could load the etoolbox
package and issue the following commands:
\makeatletter
\patchcmd{\@makecaption}{#1: #2}{#1}{}{}
\makeatother
Method 2: Remove the colon whenever (and only if) the mandatory argument of the \caption
command is empty. In this case, you may want to employ the following redefinition of the \@makecaption
command:
\makeatletter
\long\def\@makecaption#1#2{%
\vskip\abovecaptionskip\footnotesize
\sbox\@tempboxa{#2} % place contents of #2 into a scratch TeX box
\ifdim \wd\@tempboxa = 0pt % test if scratch box has zero width
\centering #1 \par % if yes, typeset only #1 (the float's name and number)
\else % if no, proceed with default definition
\sbox\@tempboxa{#1: #2}%
\ifdim \wd\@tempboxa >\hsize
#1: #2\par
\else
\global \@minipagefalse
\hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
\fi
\fi
\vskip\belowcaptionskip}
\makeatother
Best Answer
You didn't provide more details, so I assumed you're using the
article
class. In this case, you can redefine the figure number to be empty by issuing\renewcommand{\thefigure}{}
.Edit:
If it is necessary also to remove the extra spacing before the colon, one can easily modify the above command to make up for this as:
Here is an example: