I have a problem with floats and listings. Sometimes it happens that a listing is split over two pages and when a figure is near the listing it happens that the listing starts on the first page, on the next page the figure is on top of the second page and below the figure the listing continues. Is it possible to let the remainder of the listing be on the top of the second page and the figure start below the listing or on top of the third page?

closed as unclear what you're asking by jub0bs, Martin Schröder, Jesse, T. Verron, Sean Allred Mar 2 '14 at 16:49

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Welcome to TeX.SX! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Martin Schröder Mar 2 '14 at 14:29

Without a supplied example, this is untested but you can place

\global\csname @topnum\endcsname 0

after the listings environment to prevent top floats on that page (or more exactly prevent top floats on a page near there, without a forced page break the timing is a bit delicate).

  • well... i dont know what that command means but it solved two of my issues. :) Some others i solved by rearranging the figures and lstinputlisting. I will try to put a MWE. Thanks so far :) – Joysn Nov 12 '12 at 22:29

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