0

Here is my code:

\documentclass{article}
\usepackage{tikz}
\usepackage{hyperref}
\begin{document}

\section{Hello}
\subsection{Hello World}

\begin{figure}
\centering
\begin{tikzpicture}
\node[circle,draw=black,minimum size=5cm]{};
\end{tikzpicture}
\caption{Circle}
\label{fig}
\end{figure}

\pagebreak

\subsection{Hello Human}
Figure \ref{fig} demonstrates a large circle.

\end{document}

Here is how the first page of the output looks like:enter image description here

The figure has floated to the top. Is there a way I can ensure that the figure remains below section 1.1 while still be able to generate captions with figure numbers automatically and use them for cross-referencing?

Lone Learner
  • 3,226
  • 24
  • 44

1 Answers1

0

Add the float package and use [H] with your figure enviroment.

\usepackage{float}
...
\begin{figure}[H]
...
\end{figure}
  • i wouldn't recommend to use [H], it destroy float mechanism and consequently in cases, when is not enough space for image on a page, move image to the next page and left ugly white space on previous one. – Zarko Nov 14 '17 at 10:05
  • Is there any difference between h and H? Is it case-insensitive? – Lone Learner Nov 14 '17 at 10:07
  • @LoneLearner In this question you can find information about the difference. :-) And yes, both are completely different parameters. – Cragfelt Nov 14 '17 at 10:32