Is it possible to put an algorithm inside a \begin{itemize} as one of the \items?
[Tex/LaTex] Possible to put an algorithm inside a \begin{itemize}
algorithmicxalgorithmsitemize
Related Solutions
As egreg has mentioned in a comment, one option would be to use
\addtocounter{algorithm}{-1}
before \caption{Part 2}
. Another option, not requiring manually changing counters and that additionally gives you the possibility to use a customized formatting for the continued algorithm, would be to use \ContinuedFloat
from the caption
package. An example with the default caption format for \ContinuedFloat
:
\documentclass{article}
\usepackage{caption}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithm}
\caption{Part 1}
\begin{algorithmic}[1]
\Procedure {BellmanKalaba}{$G$, $u$, $l$, $p$}
\ForAll {$v \in V(G)$}
\State $l(v) \leftarrow \infty$
\EndFor
\State $l(u) \leftarrow 0$
\Repeat
\For {$i \leftarrow 1, n$}
\State $min \leftarrow l(v_i)$
\For {$j \leftarrow 1, n$}
\If {$min > e(v_i, v_j) + l(v_j)$}
\State $min \leftarrow e(v_i, v_j) + l(v_j)$
\State \Comment For some reason we need to break here!
\algstore{bkbreak}
\end{algorithmic}
\end{algorithm}
And we need to put some additional text between\dots
\begin{algorithm}[h]
\ContinuedFloat
\caption{Part 2}
\begin{algorithmic}[1]
\algrestore{bkbreak}
\State $p(i) \leftarrow v_j$
\EndIf
\EndFor
\State $l’(i) \leftarrow min$
\EndFor
\State $changed \leftarrow l \not= l’$
\State $l \leftarrow l’$
\Until{$\neg changed$}
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}
An an example with a modified format for the caption of continued floats:
\documentclass{article}
\usepackage{caption}
\usepackage{algorithm}
\usepackage{algpseudocode}
\makeatletter
\DeclareCaptionLabelFormat{algcontinued}{\ALG@name~#2 (Continued)}
\makeatother
\captionsetup[ContinuedFloat]{labelformat=algcontinued}
\begin{document}
\begin{algorithm}
\caption{Part 1}
\begin{algorithmic}[1]
\Procedure {BellmanKalaba}{$G$, $u$, $l$, $p$}
\ForAll {$v \in V(G)$}
\State $l(v) \leftarrow \infty$
\EndFor
\State $l(u) \leftarrow 0$
\Repeat
\For {$i \leftarrow 1, n$}
\State $min \leftarrow l(v_i)$
\For {$j \leftarrow 1, n$}
\If {$min > e(v_i, v_j) + l(v_j)$}
\State $min \leftarrow e(v_i, v_j) + l(v_j)$
\State \Comment For some reason we need to break here!
\algstore{bkbreak}
\end{algorithmic}
\end{algorithm}
And we need to put some additional text between\dots
\begin{algorithm}[h]
\ContinuedFloat
\caption{Part 2}
\begin{algorithmic}[1]
\algrestore{bkbreak}
\State $p(i) \leftarrow v_j$
\EndIf
\EndFor
\State $l’(i) \leftarrow min$
\EndFor
\State $changed \leftarrow l \not= l’$
\State $l \leftarrow l’$
\Until{$\neg changed$}
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}
A solution with small bullets, and your code simplified, using the nccmath
, relsize
and braket
packages. I patched the definition of the \Set
command thanks to David Carlisle to improve the spacing of the braces.
Note that "discr" is actually a math operator, and I declare it as such, in order to have better horizontal spacings.
\documentclass[11pt, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[textwidth = 15cm]{geometry}
\usepackage{lmodern, amssymb}
\usepackage{mathtools}
\usepackage{braket, relsize, nccmath}
\renewcommand\Set[1]{%
\csname Set \endcsname{\mskip-\medmuskip#1\mskip-\medmuskip}}%
\DeclareMathOperator{\disc}{disc}
\pagestyle{empty}
\begin{document}
\begin{equation}
V_{p}=\Set{%
F\in\Phi | %
\begin{medsize}\begin{array}{@{\mathsmaller{\bullet}\enspace}l@{}}
p^2 \nmid \disc(F) \quad \text{if}\enspace p \neq 2\\[1ex]
\disc(F)\equiv 1\pmod 4 \vee \disc(F)\equiv 8\vee 12
\pmod{16} \quad\text{if} \enspace p =2
\end{array}\end{medsize}
}%
\end{equation}
\end{document}
Best Answer
Yes, just don't use a floating environment.