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?
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
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}