
Я пытаюсь пронумеровать две 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
Поместите a \mbox{}
перед алгоритмом окружения (после каждого \item
)
Среду 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}