我正在尝试对两个algorithm
环境进行编号,并在它们之间留出一些空间,但我只是在旁边得到了编号?我该如何在算法之前获取数字?
代码:
\documentclass{article}
\usepackage{german,t1enc}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\usepackage{amsmath}
\renewcommand{\baselinestretch}{1.5}
\usepackage{mathtools}
\begin{document}
\begin{itemize}
\item[1.]
\begin{algorithm}[H]
\SetAlgoLined
\KwData{2 graphs T and \'{T} with nodes V and \'{V}.}
\KwResult{Find whether T and \'{T} are isomorph.}
function(T, \'{T}) \\
\Indp Find bijection of $\forall v \in V$ with $v_1, v_2 \dots , v_k$ in T so that $\pi(v)$ has the following childern $\pi(v_1), \pi(v_2), \dots, \pi(v_n)$ in \'{T}; \\
\If{the bijection is permutation}{
T and \'{T} are isomorph;
}
\end{algorithm}
\item[2.]
\begin{algorithm}[H]
\SetAlgoLined
\KwData{2 graphs T and \'{T} with nodes V and \'{V}.}
\KwResult{Find whether T and \'{T} are isomorph.}
function(T, \'{T}) \\
\Indp Find bijection of $\forall v \in V$ with $v_1, v_2 \dots , v_k$ in T so that $\pi(v)$ has the following childern $\pi(v_1), \pi(v_2), \dots, \pi(v_n)$ in \'{T}; \\
\If{the bijection is permutation}{
T and \'{T} are isomorph;
}
\end{algorithm}
\end{itemize}
\end{document}
答案1
\mbox{}
在算法环境之前放置一个(在每个之后\item
)
环境应该被提供编号的“which”而不是“etc”itemize
所取代。enumerate
\item[1.]
\documentclass{article}
%\usepackage{german,t1enc} % Is this needed?
\usepackage{enumitem}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\usepackage{amsmath}
\renewcommand{\baselinestretch}{1.5}
\usepackage{mathtools}
\begin{document}
\begin{enumerate}
\item \mbox{}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{2 graphs T and \'{T} with nodes V and \'{V}.}
\KwResult{Find whether T and \'{T} are isomorph.}
function(T, \'{T}) \\
\Indp Find bijection of $\forall v \in V$ with $v_1, v_2 \dots , v_k$ in T so that $\pi(v)$ has the following childern $\pi(v_1), \pi(v_2), \dots, \pi(v_n)$ in \'{T}; \\
\If{the bijection is permutation}{
T and \'{T} are isomorph;
}
\end{algorithm}
\item \mbox{}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{2 graphs T and \'{T} with nodes V and \'{V}.}
\KwResult{Find whether T and \'{T} are isomorph.}
function(T, \'{T}) \\
\Indp Find bijection of $\forall v \in V$ with $v_1, v_2 \dots , v_k$ in T so that $\pi(v)$ has the following childern $\pi(v_1), \pi(v_2), \dots, \pi(v_n)$ in \'{T}; \\
\If{the bijection is permutation}{
T and \'{T} are isomorph;
}
\end{algorithm}
\end{enumerate}
\end{document}