General ⇒ Aligning Algorithm
Aligning Algorithm
I was wondering, is there a way to align an algorithm in latex? For example I want an algorithm to stay in the certain section of the paper, and not just randomly jump to pages. Is there a way to do it?
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Aligning Algorithm
dragonfly wrote: I was wondering, is there a way to align an algorithm in latex? For example I want an algorithm to stay in the certain section of the paper, and not just randomly jump to pages. Is there a way to do it?
See Section 3.4.1 (Placement of Algorithms) of the documentation (linked from here).
Section 3.4.1 (Placement of Algorithms) of [i]algorithms[/i] documentation wrote: One important fact that many users may not have noticed is that the algorithm
environment is actually built with the float package and float, in turn, uses
David Carlisle’s here style option. This means that the floats generated by the
algorithm environment accept a special option, namely, [H], with a capital ‘H’,
instead of the usual ‘h’ offered by plain LaTeX.
This option works as a stronger request of "please put the float here": instead
of just a suggestion for LaTeX, it actually means “put this float HEREâ€, which
is something desired by many. The two algorithms typeset in this document use
this option.
Warning. You can’t use the ‘H’ positioning option together with the usual ‘h’
(for “hereâ€), ‘b’ (for “bottomâ€) etc. This is a limitation (as far as I know) of
the float.sty package.
So I think you want...
Code: Select all
\begin{algorithm}[H]
%...
\end{algorithm}