Figure placement after first time referenced in text

cross-referencingfloatspositioning

I'm writing a master's thesis and was told that I could place figures anywhere, as long as they appear after the first time I reference them in the text. It seems to be a good practice around here, so I thought LaTeX might have a command for that, but I can't find that in the common figure positioning options. Is there an existing option to place figures anywhere after their first referencing?

edit:
I'm looking for an elegant solution which avoids the use of the dreaded [h!] or [H], leaving more freedom to LateX for the placement of the figures. I'm also trying to avoid manual placement for every figure.

So far I've just been using free figure placement, introducing figures as such:

\begin{figure}
    \centering
    \includegraphics[width=0.8\textwidth]{name_of_fig.PNG}
    \caption{What a beautiful figure}
    \label{fig:a_fig}
\end{figure}

Best Answer

The base latex release includes the flafter package that ensures floats never float "back" to the top of the current page before their definition in the source. So you just need to place the figure environment at or after its first \ref to meet your requirement.