5

I am using the package algorithm2e. I have a document with several algorithms. I use the float position option [ht], but all my algorithms are positioned at the end of the chapter; none at the position or on the next page. I tried the package float as suggested in this post Floating an algorithm?. But the algorithms looked very different and wrong after that. Does anyone have an idea how I position my algorithms at 'here' or the top of the next page?

3
  • For any kind of float, using an optional argument that does not include p vastly increases the chance of floats going to the end of document. Perhaps [!htp] will do what you want. Commented Nov 25, 2012 at 19:30
  • Ok they are not at the end anymore, but also not really flaoted. There is no text around them on some pages. Is that not possible? Commented Nov 25, 2012 at 19:38
  • well that's a float page (p) whether the floats fit on text pages depends what else is there and you haven't shown. But if they are large (say more than half a page) it gets hard to fit them in if there are other unbreakable objects such as section heads or images. the ! says to ignore all stylistic constraints like number of floats allowed per page so latex will fit them if it thinks they physically fit without leaving the page breaks unacceptably bad. Commented Nov 25, 2012 at 19:43

1 Answer 1

12

For any kind of float, using an optional argument that does not include p vastly increases the chance of floats going to the end of document. Perhaps [!htp] will do what you want.

Here ! says LaTeX should ignore most of the stylistic constraints such as the proportion of the page allowed for floats or the number of floats per page and so it will place the floats if the page breaks are not unacceptably bad.

Note [!htp] disallows bottom floats you could also use [!ht] which would disallow page floats but whenever you shorten the optional argument in this way you remove some possibilities for float positioning so make it more likely the float can not be positioned at all in which case it will be held up until end of document.

1
  • This advice about p was super useful, thanks. I didn't realize that was what was happening because my floats were only going to the end of the section (thanks to placeins). Commented Apr 7, 2023 at 2:56

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.