Document Classes ⇒ Algorithms over several pages
Algorithms over several pages
I'm using the algorithms package to display pseudocode. I put an algorithmic environment inside an algorithm environment, which numbers the different algorithms nicely and makes them show up in a list of algorihms in the beginning (analogous to a list of figures/tables). However, it also turns the algorithm into a floating object and this seems to prevent Latex from introducing page breaks.
I now have an algorithm that is more than one page long. What Latex does is the following: It just continues the text on one page until it leaves the page at the bottom and disappears into nirvana.
Any ideas what I should do to have Latex introduce page breaks where necessary? Or is there a way to force them myself?
Thanks a lot!
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Re: Algorithms over several pages
Regards,
B.A.
Re: Algorithms over several pages
Any ideas about a good way (preferably automatic) to do so? Especially that my algorithms are inside a document, and I do insert and delete text from the document so often, so a manual way to handle that problem with algorithms will be very hectic!
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Algorithms over several pages
Study the according manuals to learn more about the packages.
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Algorithms over several pages
I had the same problem. As the manual states:
So yes you can but not as a float Algorithm package. You need to use the algorithmic environment. But as some other people suggested, do you really need several pages to describe pseudocode? Maybe it is a good idea to abstract away some tasks as secondary algorithms. That is what I did at the end and it was much easier to follow. Also if you use the algorithmic environment you will loose the ability to number them and display them in the list of contents.4.1 General
When placed within the text without being encapsulated in a floating environment
algorithmic environments may be split over a page boundary, greatly
detracting from their appearance.2 In addition, it is useful to have algorithms
numbered for reference and for lists of algorithms to be appended to the list
of contents. The algorithm environment is meant to address these concerns by
providing a floating environment for algorithms.
Cheers
-
ThoughtSearcher
- Posts: 1
- Joined: Fri Jan 14, 2011 7:12 pm
Re: Algorithms over several pages
1. Use \algstore{some_name} as the last command of your algorithm block (the line after which you want to split the algorithm)
2. Use \algrestore{some_name} as the first command of new algorithm block. Paste your remaining code below this command in this new algorithm block.
Make sure you use the same name in \algstore and \algrestore.