TransWikia.com

How to stop numbering for a figure

TeX - LaTeX Asked by Joseph Holten on June 19, 2021

so I have multiple graphics in my Latex document, and have wrapped them in figure enviornments for easy positioning. How can I have one of my figures not count towards the overall figure counter in this chapter?
So I have figure A, it contains three subcaptions. I give them each a subcaption* (so the one without the label), and then I have figure B and want to give it a caption, and want it to be called Figure 1.1 (instead of Figure 1.2)

Here is an example of what I mean:

documentclass{report}
usepackage{tikz}
usepackage{caption, subcaption}

begin{document}

section{A Section}
This is Figure A
begin{figure}[h] % Figure A (should be excluded from the count)
    centering
    begin{subfigure}{.3textwidth}centeringbegin{tikzpicture}
        draw (0,0) rectangle (1,1);   
    end{tikzpicture}subcaption*{(i)}
    end{subfigure}%
    begin{subfigure}{.3textwidth}centeringbegin{tikzpicture}
        draw (0,0) rectangle (1,1);
    end{tikzpicture}subcaption*{(ii)}
    end{subfigure}%
    begin{subfigure}{.3textwidth}centeringbegin{tikzpicture}
        draw (0,0) rectangle (1,1);
    end{tikzpicture}subcaption*{(iii)}
    end{subfigure}
end{figure} parnoindent
This is Figure B:
begin{figure}[h]centeringbegin{tikzpicture}  % Figure B (should be included into the count and here be % Fig. 1.1.
    draw (0,0) circle (20pt);
end{tikzpicture}caption{B}end{figure}

end{document}

Here is the output:

output

2 Answers

The subcaption package needs to increase the figure (or table) counter in order to affix the right number to the subfigure number even when the main caption is at the bottom.

When it finds the caption command (which will step up the counter), it steps the counter down so the final results agree. In your case the counter is never stepped down.

Solution: step down the counter manually. I suggest defining a nocaption declaration to this effect.

documentclass{report}
usepackage{tikz}
usepackage{caption, subcaption}

makeatletter
newcommand{nocaption}{addtocounter{@captype}{-1}}
makeatother

begin{document}

section{A Section}

This is Figure A

begin{figure}[htp] % Figure A (should be excluded from the count)
centering

    begin{subfigure}{.3textwidth}centeringbegin{tikzpicture}
        draw (0,0) rectangle (1,1);   
    end{tikzpicture}subcaption*{(i)}
    end{subfigure}%
    begin{subfigure}{.3textwidth}centeringbegin{tikzpicture}
        draw (0,0) rectangle (1,1);
    end{tikzpicture}subcaption*{(ii)}
    end{subfigure}%
    begin{subfigure}{.3textwidth}centeringbegin{tikzpicture}
        draw (0,0) rectangle (1,1);
    end{tikzpicture}subcaption*{(iii)}
    end{subfigure}

nocaption

end{figure}

This is Figure B:

begin{figure}[htp]
centering

    begin{tikzpicture}
    draw (0,0) circle (20pt);
    end{tikzpicture}

caption{B}

end{figure}

end{document}

enter image description here

Correct answer by egreg on June 19, 2021

You could add caption{A} into the closing line of your first figure. caption{A}end{figure} parnoindent

But similar to Sigurs comment, you would get 2 separate figures, listed as 1 and 2 and no subfigures. As far as i know, there is no deeper nesting to subsubfigures.

Answered by 6equj5 on June 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP