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?
1 Answer
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.
-
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).Jazz Weisman– Jazz Weisman2023-04-07 02:56:25 +00:00Commented Apr 7, 2023 at 2:56
pvastly increases the chance of floats going to the end of document. Perhaps[!htp]will do what you want.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.