In a long latex doc I have I get my algorithm inserted into my definition for some reason. I apologize for not having a small working example I could not get one to work. Have a bunch of overfull and underfull errors can that actually cause a problem? And what would be the easiest way to fix such? See here:

enter image description here

 \STATE $ c \leftarrow  w.$
 \STATE $S = \{u \in V : w(u) = 0 \}$.
\WHILE{$S$ is not a hitting set for $C$} 
\STATE  $\mathcal{M} $  a collection of cycles returned by a violation oracle Violation$(G, C, S)$.
\STATE $c_{ \mathcal{M} (u) } \leftarrow |{M _ M : u _ M}|, \forall u \in V $.
 \STATE $ \alpha 
\leftarrow min_ {u \in V \backslash S} | w(u)| /
c_{\mathcal{M} (u) } $
w(u) } \leftarrow  w(u) - \alpha cM (u),$ for all u in V.
$ S \leftarrow \{u _ V : w(u) = 0 \}. $
return a minimal hitting set $ H \subset S $ of $\mathcal{C}$.

For $p \geq 3$ a $p$-pocket for a planar graph G(V; E) and a cycle collection $\mathcal{C}$, is a set U $\subset$ V such that: \\
 1. The set U contains at most $p$ nodes  with neighbors outside U. (we call these contact nodes) \\
 2. The induced subgraph $G_S [U]$ has at least p faces in $\mathcal{C}$.
  • Please, even if you don't have a very MWE, please insert at list one that is workable so one can use to test a solution. – gvgramazio May 1 '18 at 10:51
  • I think that it happens because LaTeX prefers to non break a page inside the algorithm environment. In this case you can manually insert a \newpage before your definition or you can redefine the algorithm environment. – gvgramazio May 1 '18 at 10:53
  • You can also try to pass the optional argument H to the algorithm environment. – gvgramazio May 1 '18 at 11:20
  • Thank you that did the trick btw what does the [H} do? – Hao S May 1 '18 at 18:23
  • I provided an answer that should clear your doubts, if you have other doubts please ask. – gvgramazio May 2 '18 at 9:14

I know that is a bad practive to copy-paste the answer from the manual but there is a subsection that is clearly the answer to your question.

4.4.1 Placement of Algorithms

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. [...]

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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