is there a way to enumerate figures in the order they actually appear in the document, and not in the order they were declared in the source file?
I have the following source:
\documentclass{article}
\usepackage{float}
\begin{document}
TEXT1
\begin{figure}[p]
\caption{Figur A}
\end{figure}
TEXT2
\begin{figure}[H]
\caption{Figur B}
\end{figure}
TEXT3
\end{document}
which yields the following two pages:
TEXT1
TEXT2
+++++++++++++++
+ +
+ FIGUR B +
+ +
+++++++++++++++
Fig 2: Figur B
TEXT3
---new page---
+++++++++++++++
+ +
+ FIGUR A +
+ +
+++++++++++++++
Fig 1: Figur A
So, how these two figures appear is exactly what I want, but it is really bad that in the output document, figure 2 comes before figure 1. This is also ugly in the table of figures:
Fig 2 "Figur B" page 1
Fig 1 "Figur A" page 2
What I want is, that iff tex decides to put figure B after figure A, then it should give figure B the number 1 and figure A the number 2.
I know there are some dirty hacks (setcounter; move figures in source), but obviously I'd like to have an elegant solution.
Thanks!
Best Answer
Under normal circumstances, LaTeX always outputs floats of a given type -- say,
figure
-- in the sequence in which they are encountered in the document. However, theH
location specifier falls outside of "normal" circumstances. To achieve its objective,H
deliberately steps outside of what is normal.There are only two possible remedies:
Don't use the
[H]
location specifier. Consider using[ht!]
instead.Or, as @Zarko has already commented, if you insist on using
[H]
anyway, be prepared to insert\clearpage
before typing\begin{figure}[H]
.