# Change caption of a single/few figures

The captions of my figures read, as usual, "Figure #: some text". I want a few of them, which are scattered through the text, to read "Diagram #: some text" (the counter being consecutive). What is the right way to do this? Should I define a new float environment?

Here, a minimal example:

\documentclass{article}
\usepackage{amssymb,latexsym,amsmath}
\usepackage{amsmath,amsthm,amssymb,pstricks,pst-node}
\begin{document}

Some text, and then:

\begin{figure}[htb]
$\text{This is a figure}$
\caption{Ok. Here I like the label figure}
\end{figure}

Now:

\begin{figure}[htb]
$\begin{array}{cc} \Rnode{a}{A} & \Rnode{b}{B} \end{array} \ncLine{a}{b}\Aput{}$
\caption{Wrong! Here I would like the caption to say Diagram 2:...''}
\end{figure}

and finally:

\begin{figure}[htb]
$\vspace{-.1cm} \setlength{\arraycolsep}{1.8cm} \text{This is another figure}$
\caption{Ok. Here I like the label figure}
\end{figure}

\end{document}

-

First solution Temporarily redefine the \figurename to Diagram within the figure environment. (Thanks to Torbjorn for his reminder about the group feature of figure)

\documentclass{article}
\usepackage{amssymb,latexsym,amsmath}
\usepackage{amsmath,amsthm,amssymb,pstricks,pst-node}
\begin{document}

Some text, and then:

\begin{figure}[htb]
$\text{This is a figure}$
\caption{Ok. Here I like the label figure}
\end{figure}

Now:

\begin{figure}[htb]
\renewcommand{\figurename}{Diagram}%
$\begin{array}{cc} \Rnode{a}{A} & \Rnode{b}{B} \end{array} \ncLine{a}{b}\Aput{}$
\caption{Wrong! Here I would like the caption to say Diagram 2:...''}
\end{figure}

and finally:

\begin{figure}[htb]
$\vspace{-.1cm} \setlength{\arraycolsep}{1.8cm} \text{This is another figure}$
\caption{Ok. Here I like the label figure}
\end{figure}

\end{document}


Edit -- Alternate Version using \usepackage{caption}

\documentclass{article}
\usepackage{amssymb,latexsym,amsmath}
\usepackage{amsmath,amsthm,amssymb,pstricks,pst-node}
\usepackage{caption}
\begin{document}

Some text, and then:

\begin{figure}[htb]
$\text{This is a figure}$
\caption{Ok. Here I like the label figure}
\end{figure}

Now:

\begin{figure}[htb]
\captionsetup{name=Diagram}
$\begin{array}{cc} \Rnode{a}{A} & \Rnode{b}{B} \end{array} \ncLine{a}{b}\Aput{}$
\caption{Not longer Wrong! Here I get the caption to say Diagram 2:...''}
\end{figure}

and finally:

\begin{figure}[htb]
$\vspace{-.1cm} \setlength{\arraycolsep}{1.8cm} \text{This is another figure}$
\caption{Ok. Here I like the label figure}
\end{figure}

\end{document}


-
As the figure environment creates a group, you could just add the \renewcommand within the figure(s) that should be diagram(s), storing the original isn't necessary then. Edit: Similar to what you've done with \captionsetup. –  Torbjørn T. Apr 25 '14 at 12:13
@TorbjørnT. You are right, I forgot about the group feature –  Christian Hupfer Apr 25 '14 at 12:16
Thanks, definitely a simple and flexible answer. –  UBIK Apr 25 '14 at 12:16