1

I am writing a report where I have figures (floats) and also code snippets. I am using graphicx and minted, respectively for the figures and code. I know that you aren't supposed to use [h] for figures, rather something like [ht], but when I do this, the figures break up my code, and I would like for this not to happen. I tried doing just [h], but LaTeX just changed it to [ht]. Is there a way to prevent the figures from breaking up my code?

Robert
  • 11
  • Welcome to TeX.SX! Possibly give LaTeX more flexibility e.g. htbp, possibly force placement, possibly change how you're setting code. Could you add an example of compilable code which illustrates how you're adding figures and code, and demonstrates the undesirable breaking? – Dai Bowen Mar 30 '23 at 18:00
  • 1
    When [h] is not possible for some reason, next most reasonable alternative to be "almost [h]" is usually [t], so this is done automatically. Using [h!] could prevent some of this cases (e.g. allowing more floats per page) and [H] (float package) will do exactly what you want, but in this case you will pay to fix the positions with (a) beautiful huge gaps, or (b) floating (i.e., moving) the floats yourself in the source code to avoid fixed figures at the end of pages. – Fran Mar 30 '23 at 18:21
  • [H] seemed to do what I want. Thanks! – Robert Mar 30 '23 at 18:43
  • Yes it did. Thanks again. – Robert Mar 30 '23 at 19:18
  • Thinking a bit more, using [htbp] and placing \FloatBarrier from placeins just before your first code snippet to ensure all figures are issued before the code starts being printed is a better approach if the aim is mainly to keep figures out of a certain region in the document. – Dai Bowen Mar 30 '23 at 21:10

0 Answers0