I have noticed that table or figure is sometimes (I haven't figured the pattern yet) automatically placed before its reference, regardless of the code and [!h] (or [!ht]). Is it possible to turn this off? Better said, can I stop LaTeX playing with MY figures and tables (and do everything manually)?
Asked
Active
Viewed 2,393 times
2
Vochmelka
- 965
1 Answers
3
While using minipages or simply using \includegraphics and adding \caption using \captionof{figure}{Caption text} from either caption or capt-of package (both provide that macro) is a good idea, you can take shelter under the H position specifier of float package. [H] removes the floating nature of floats.
\documentclass{article}
\usepackage{graphicx,kantlipsum}
\usepackage{float}
\begin{document}
Figure~\ref{fig:myfig} referred here.
\kant[1-2]
\begin{figure}[H]%[t] %% change to [t] and see the difference
\centering
\includegraphics[width=4cm]{example-image-a}
\caption{My figure}\label{fig:myfig}
\end{figure}
\kant
\end{document}

As a side note there is flafter package that ensures the floats appear after they are first referred in text (to some extent). You have to add \usepackage{flafter} in your preamble.
minipages and provide a caption using\captionoffrom thecaptionorcapt-ofpackages. – Gonzalo Medina Feb 18 '14 at 00:16tables andfigures are meant to float. By using those environments, you are explicitly asking TeX to work out the best place to put them. That placement can be influenced but TeX will ultimately make the decision. If you don't want TeX to move them, don't use those environments. Use e.g.tabularor whatever instead. – cfr Feb 18 '14 at 00:38