LaTeX Inserting Figures in LaTeX: Removing "Figure 1"

  • Thread starter Thread starter Juggler123
  • Start date Start date
  • Tags Tags
    Latex
AI Thread Summary
To customize figure captions in LaTeX and remove the "Figure 1:" prefix, users can redefine the \@makecaption macro. By inserting specific code before the \begin{document} command, the caption can be modified to display only the text, such as "Close-up of a gull," without the figure number. The provided code alters how captions are processed, specifically by eliminating the inclusion of the figure number in the output. This solution allows for a cleaner presentation of captions while maintaining the formatting integrity of the document. Users are encouraged to copy and paste the code directly if they prefer not to delve into the details of LaTeX syntax.
Juggler123
Messages
80
Reaction score
0
Hi I have a problem inserting figures into latex, if I write the following script;

\begin{figure}
\centering
\includegraphics[width=0.5\textwidth]{gull}
\caption{Close-up of a gull}
\label{gull}
\end{figure}

I get a picture of gull and underneath it says Figure 1: Close-up of a gull

That's fine but I need it to say JUST

Close-up of a gull

Is there anyway of getting rid of the "Figure 1:" part!?

Any help would be great. Thanks.
 
Physics news on Phys.org
There are probably some LaTex packages that let you do this cleanly, but the following works. Change the \@makecaption macro, which outputs the caption.

Put this code just before \begin{document}

Code:
\makeatletter
\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \sbox\@tempboxa{#2}%
  \ifdim \wd\@tempboxa >\hsize
    #2\par
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}
\makeatother

The original version (in the book and article styles) had the lines
\sbox\@tempboxa{#1: #2}%
and
#1: #2\par

Parameter #1 is the figure number, #2 is the text of the caption.

If should be fairly obvious what the changes do to the output format. The rest of the code is to decide if the caption is short enough to fit on one line or needs a complete paragraph. If you only want to use LaTeX rather than understand it, just copy and paste!
 

Similar threads

Replies
4
Views
3K
Replies
2
Views
3K
Replies
5
Views
4K
Replies
7
Views
3K
Replies
3
Views
2K
Replies
2
Views
5K
Replies
2
Views
3K
Back
Top