I've used LaTeX to author something approaching 100 scientific papers, and while I love the equation rendering and the ease of referencing, I dislike in almost equal measure the inability to dictate image locations.

My papers are often (a) short and (b) full of figures. I usually know where I want those images to go, e.g. Fig 1 at the bottom of page 1, etc. I would like to specify this to LaTeX have have the system obey me absolutely, rather than taking my placement instructions as suggestions. I would like LaTeX to wall off the regions I specify, such as the bottom of page 1, and then do its best to flow the text and equation layout around those absolute, non-negotiable constraints.

Many hours of googling has failed to uncover a means to do this; instead I find lots of tricks for increasing how emphatic my "suggestion" is to LaTeX by, say, putting [h] or [h!], or even altering LaTeX's parameters for how important its various layout desiderata are (tolerances of overflow, space around figures etc.). While better than useless, these solutions fall far short of the "do as you are told" imperative I'm seeking. Is it possible?

  • It is possible to tell TeX to avoid all floats on the top of a page. Is this what you want? – Sigur Nov 21 '13 at 23:31
  • 2
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Don't use floats if you don't like them... you freak :p If you wish to retain some floating capability, you may want to look into the placeins package and its \FloatBarrier command. – jub0bs Nov 21 '13 at 23:33
  • Related tex.stackexchange.com/a/39020/14757 – Sigur Nov 21 '13 at 23:33

[h] (and [!h]) is essentially a syntax error that requests all figures go to the end of the document latex usually gives a warning and changes that to [ht] to give itself a chance. You may prefer to not use a float at all and just use capt-of package so you can just include the figure and then do \captionof{figure}{zzzz}

Stopping floats though puts floats exactly where you put them in the text stream whereas (I think) you want to put them where you want on the page. This isn't really supported in latex unless you re-write half of it, which is what the LaTeX3 xor package aims to do, and does (or has had in some of its incarnations over the years (it pre-dates LaTeX2e in parts) the ability to specify that floats go in specific regions eg top float on page 6 or margin float on page 2. However xor isn't really usable for real documents at present it is more of an experimental testbed than something you can use today.

However all is not lost, but you need to give LaTeX a chance. Don't use h for a start if you want figures to go in areas such as "bottom of page 1" as the main effect of [h] is to prevent the float being placed in any of the normal float areas as it means not-top, not-bottom and not-float-page.

If you put a figure in the text so it falls on page 1 and use [!b] then it will go on the bottom of that page unless it doesn't fit (or unless you put some other big unbreakable thing like a large table) on the same page.

  • Thanks for your reply. I am familiar with [t] [b] and the like. As I mentioned they are better than useless but far weaker that what I want, which is a way to absolutely dictate page location. Your answer indicates that this is not possible in LaTeX as it is now. I will check out the xor package, thanks for that. However since most journals I use require LaTeX2e compatibility, I guess that can only be at best a solution for my personal documents rather than my publications. – user41474 Nov 22 '13 at 0:03
  • 1
    @user41474 note I specifically suggested [!b] not '[b]` if the shriek version doesn't work it means that the figure doesn't fit (ie you may need to alter the other text on the page eg break up a large table to leave room for your figure. The alternative (easier for bottom of page) is to not use a float at all but attach the image to the page foot, and use \enlargethispage with a negative amount to shrink the text area to compensate. – David Carlisle Nov 22 '13 at 0:09
  • I should have specified that I typically use the [!b], or [!t] etc versions, but that they are often insufficient to impose my will on LaTeX. The idea of attaching the image to the page foot is interesting, I'll certainly try that - is it strsightforward? – user41474 Nov 22 '13 at 0:30
  • @user41474 not including p in the optional argument is a major cause of figures floating to the end of the document. Although using them with if necessary using a forced \clearpage (not \newpage) gives you pretty complete manual control actually, adding to the foot isn't that hard – David Carlisle Nov 22 '13 at 0:49
  • @user414 you might also want to look at Frank's extension to multicol here tex.stackexchange.com/a/57750/1090 that allows you to specify a float goes on a specific page/column – David Carlisle Nov 22 '13 at 12:45

The biggest trick is that you don't have to use floats at all! They are, in many cases, not the right tool for the job. In fact, I'd say most of the time they are the wrong tool, at least with the default settings. Not everyone agrees with me, of course (See the comments here). Then once you place it, it will stay with that bit of text. It isn't perfect, as it stays with text, not position, but if you've finalized that document mostly you can just stick it with text near the position you want. I've done things that way, though they are a bit of a pain.

If you want an image just toss in


or whatever at the point you want it.

You can use the caption package to add captions:

Hi! I'm a test

\captionof{figure}{An example}
\vspace{0.2 \baselineskip} %I find this makes the figure stand out more nicely. 

ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn

You'll need a test.png or something like that to make this work, but you can see it is quite simple. You can also do the same thing for tables. Then they don't move on you at all.

Other useful things I've heard about: \FloatBarrier (from the placeins package), which creates a line which all floats much appear before. I've never used it, but its been recommended to me. This again locks based on text, but you can move it as needed, as above, if H and such aren't working for you, as they never seem to do for me.

When I was writing my thesis I found adding

%Make latex put figures with text more

To my preamble made floats suck a lot less. They still moved, but wouldn't all move to blank pages when I wanted to add a few large figures to the document; they'd mostly stay where they should, with just some tweaking required. This made them more likely to stay roughly where I wanted them.

  • that ties the image to a fixed place in the text stream, the OP wants to tie the image to a fixed place on the page (which is a lot harder) – David Carlisle Nov 22 '13 at 0:11
  • @DavidCarlisle oh, good point. Should I remove my answer? It can work, I've done it this way by finalizing the text, then moving the minpage around in the text until it inserted where I wanted it. A pain, but it worked. – Canageek Nov 22 '13 at 0:15
  • No harm in leaving the answer, latex basically doesn't support the request so any answer involves a certain amount of pain:-) – David Carlisle Nov 22 '13 at 0:21
  • While I do indeed want to pin images to specific page locations and have the text flow around it as I write my paper, this solution does at least seem to allow me to force the positioning I want as a final step before sending out the document. I will try it. – user41474 Nov 22 '13 at 0:31
  • @user41474 There IS another way I have seen, it was in a article on how to do presentations in LaTeX. However the code was scary and this is easier. Typically I want the Figure to go with the text when I'm writing papers, so this is what I know, but if I come across that article, I'll let you know. I think it used pgf. – Canageek Nov 22 '13 at 0:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.