有没有办法从算法中的行号中删除冒号(:)(使用包algpseudocode
)?
\documentclass{article}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithmic}[1]
\Function{Euclid}{a,b}
\State r\gets a\bmod b
\If{r\not=0}
\While{r\not=0} \Comment{We have the answer if r is 0}
\State a\gets b
\State b\gets r
\State r\gets a\bmod b
\EndWhile
\EndIf
\State \Return b \Comment{The g.c.d. is b}
\EndFunction
\end{algorithmic}
\end{document}
我们会得到
答案1
您必须重新定义\alglinenumber
:
\documentclass{article}
\usepackage{algpseudocode}
\algrenewcommand\alglinenumber[1]{\footnotesize #1}
\begin{document}
\begin{algorithmic}[1]
\Function{Euclid}{$a,b$}
\State $r\gets a\bmod b$
\If{$r\not=0$}
\While{$r\not=0$} \Comment{We have the answer if $r$ is $0$}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$
\EndWhile
\EndIf
\State \Return $b$ \Comment{The g.c.d. is $b$}
\EndFunction
\end{algorithmic}
\end{document}