Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Possible Duplicate:
How to avoid splitting tables between sections

I did something like this:











    algorithm goes here





    algorithm goes here




section contents.


When I render the PDF, the test section appears before the second algorithm, instead of after it. Isn't LaTeX supposed to render them in the above order?

share|improve this question

migrated from Nov 5 '11 at 21:09

This question came from our site for professional and enthusiast programmers.

marked as duplicate by lockstep, cmhughes, Jake, Torbjørn T., Stefan Kottwitz Nov 6 '11 at 11:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Also, which package are you using here? Neither the environment algorithm nor algorithmic is part of the LaTeX kernel or the standard classes. Please edit your question to add a complete example there (including the preamble), this spares us guessing the packages your are using. – Paŭlo Ebermann Nov 5 '11 at 20:41
@mak89k: The algorithm environment is a "floating" environment. The answers in the linked question about tables also apply to algorithms. – lockstep Nov 5 '11 at 21:27
Welcome to! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. – Werner Nov 5 '11 at 21:29

1 Answer 1

Algorithm is a floating environment. So, you need to put a [!h] next to it if you want it to appear exactly where you're putting it. Like so:

share|improve this answer
[!h] is not enough so avoid floating. It reduces floating only. To avoid floating don't use floats and to avoid floating after a section use placeins. See the link at lockstep's comment above for more information. – Schweinebacke Nov 6 '11 at 11:57

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