Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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} 
share|improve this question

1 Answer 1

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} 

enter image description here

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} 

enter image description here

share|improve this answer
    
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 at 12:13
    
@TorbjørnT. You are right, I forgot about the group feature –  Christian Hupfer Apr 25 at 12:16
    
Thanks, definitely a simple and flexible answer. –  UBIK Apr 25 at 12:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.