重命名算法标题

重命名算法标题

如何将算法标题名称从 重命名Algorithmsome name。这是我的代码:

\documentclass[oneside,a4paper  , 12 pt, titlepage]{book}


\usepackage{algorithmicx}
\usepackage{algorithm}
\usepackage{listings}
\usepackage{algcompatible}
\usepackage{algpseudocode}

\renewcommand*{\ALG@name}{Algoritma}


\begin{document}
\begin{algorithm}[h!]
\caption{Algoritma direct search}\label{direct search}
\begin{algorithmic}[1]
\Procedure{Direct-Search}{$G$}
\For{$i \gets  1,\, G.length$}
    \For {$j \gets 1, \, i- 1$}
        \State  $r \gets  \Call {distance}{G_i ,G_j} $
        \If {$r \le treshoold $ }
            \State  $ \Call{calculate-interaction}{G_i,G_j}$
        \EndIf 
    \EndFor 
\EndFor
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}

我的错误:

Missing \begin{document}. \renewcommand*{\ALG@name}

答案1

由于您的重新定义具有字符,因此@您需要\makeatletter\makeatother

\makeatletter
\renewcommand*{\ALG@name}{Algoritma}
\makeatother

代码:

\documentclass[oneside,a4paper  , 12 pt, titlepage]{book}
\usepackage{algorithmicx}
\usepackage{algorithm}
\usepackage{listings}
\usepackage{algcompatible}
\usepackage{algpseudocode}

\makeatletter
\renewcommand*{\ALG@name}{Algoritma}
\makeatother

\begin{document}
\begin{algorithm}
\caption{Algoritma direct search}\label{direct search}
\begin{algorithmic}[1]
\Procedure{Direct-Search}{$G$}
\For{$i \gets  1,\, G.length$}
    \For {$j \gets 1, \, i- 1$}
        \State  $r \gets  \Call {distance}{G_i ,G_j} $
        \If {$r \le treshoold $ }
            \State  $ \Call{calculate-interaction}{G_i,G_j}$
        \EndIf 
    \EndFor 
\EndFor
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}

在此处输入图片描述

我建议您不要使用诸如此类的限制性放置选项[!h]

相关内容