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:

    \caption{What a beautiful figure}

2 Answers 2


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.

  • Yay, it works! Thank you for this perfectly appropriate solution. I can now meet my formatting requirements while using LaTeX :)
    – Elena
    Apr 21, 2022 at 14:21

so what I did in my Thesis is that I wrote my text, then reference it with \ref{fig:foo} and then placed my figure with


Because of the [h!] you can make sure, that LaTeX will place it right after the text, even if it isn't the quote on quote best place (might result in some white spaces in between following or previous text etc.).
I can't tell if it is state of the art or if there are more elegant ways to do this, but maybe this will help you. Good luck on your Thesis.

  • Thank you! But I'm indeed looking for a more elegant solution to this, that would leave LateX more freedom in figure placement than the dreaded [h!]
    – Elena
    Apr 19, 2022 at 20:42
  • Understandable. I on my part am afraid, that i won't be able to give you an answer then, but someone surely is. You might want to edit your post and specify that you don't want the [h!] option and even show how you did it so far. @Elena
    – Hoerbii3
    Apr 19, 2022 at 20:47
  • 1
    Alright, I'll do that, thanks for the suggestion and the advice!
    – Elena
    Apr 19, 2022 at 20:49
  • 2
    [h!] does not ensure the float comes at that position, it will usually generate a warning and latex will change it to [!ht] allowing it to come at the top of any later page (which does meet the OP's requirement, but not really as you describe here.) Apr 19, 2022 at 23:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .