\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{latexsym}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\SetCommentSty{mycommfont}
\usepackage[linkbordercolor={0 0 1}]{hyperref}
\usepackage{nameref}
\renewcommand{\labelitemi}{$\bullet$}
\usepackage{enumerate}
\usepackage{caption}
%\captionsetup[figure]{labelfont=bf}
\captionsetup{labelsep=none}
\usepackage{subcaption}
\usepackage[compatibility=false]{caption}
\RestyleAlgo{boxruled}
\LinesNumbered
\usepackage{amsmath,amssymb,fancyhdr,url}
\usepackage{graphicx}
\usepackage{mathrsfs}
\usepackage{tabularx,environ,amsmath,amssymb}
\begin{document}
\begin{algorithm}[H]
\SetAlgoLined
\textbf{Input} : An a $p^t$, prime $p$,
integer $t$ and data s above\;
\textbf{Find} : A swq $G$\;
\vspace{0.3cm}
\textbf{begin}\;
\hspace{0.5cm} $L =\phi;B=\phi$\;
\hspace{0.5cm} repeat\;
\hspace{1cm} select largest ord$_G(a)$\;
\hspace{1cm} $B=B\cup \{a\}$\;
\hspace{1cm} $L^{'} $\;
\hspace{1cm} \textbf{for} (each $b \in L^{'}$) remove all elements in
$U(b)$ from $M$\;
\hspace{1cm} $L=L\cup L^{'}$\;
\hspace{0.5cm} until $(\sum_{a_j \in B}R(a_j) =t)$\;
\textbf{end}
\caption{Algorithm}
\end{algorithm}
\end{document}
问题 :如何设计算法的开始和结束语句之间的垂直线?
查看输出:
答案1
您需要使用由定义的关键字algorithm2e
。这里有一个更好的标记,可以做到这一点:
\documentclass{article}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\SetKwInOut{KwInput}{Input}
\SetKwInOut{KwFind}{Find}
\begin{document}
\begin{algorithm}
\SetAlgoLined
\KwInput{An a $p^t$, prime $p$, integer $t$ and data s above}
\KwFind{A swq $G$}
\BlankLine
\Begin{
$L = \phi$; $B = \phi$\;
\Repeat{$\sum_{a_j \in B} R(a_j) = t$}{
select largest $\mathrm{ord}_G(a)$\;
$B = B \cup \{a\}$\;
$L'$\;
\For{each $b \in L'$}{
remove all elements in $U(b)$ from $M$\;
}
$L = L \cup L'$\;
}
}
\caption{Algorithm caption}
\end{algorithm}
\end{document}