Possible Duplicate:
Remove colon in the caption of a figure without using caption package
This is a very tough question and I have posted minimum example below.
- Because I don't want my figures to float I use center environment and capt-of package.
- I have tweaked @makecaption in a way that there is only figure name (no colon) displayed when figure name is empty.
- I also use hyperref package.
When working all three together, I get bunch of "Extra \else." errors. Can you find the problem? Maybe I have redefined @makecaption badly?
Regards.
\documentclass{article}
\usepackage{capt-of}
\usepackage{hyperref}
\makeatletter
% tweaked article.cls @makecaption: no caption text no ":"
\newcommand*{\captionlabeldelim}{}
\long\def\@makecaption#1#2{%
\ifx #2\ignorespaces
\renewcommand*{\captionlabeldelim}{}
\else
\renewcommand*{\captionlabeldelim}{:\ }
\fi
\vskip\abovecaptionskip
\sbox\@tempboxa{#1\captionlabeldelim #2}%
\ifdim \wd\@tempboxa >\hsize
#1\captionlabeldelim #2\par
\else
\global \@minipagefalse
\hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
\fi
\vskip\belowcaptionskip}
\makeatother
\begin{document}
\begin{center}
\includegraphics[clip]{bla.eps}
\captionof{figure}{x}
\end{center}%
\begin{center}
\includegraphics[clip]{bla.eps}
\captionof{figure}{}
\end{center}%
\end{document}

caption? It's much easier instead of redefining something. – Marco Daniel Aug 10 '12 at 13:50