算法标题如何写成中文的?

发布于 2021-04-25 01:14:34

如图片所示,如何将其中的“Algorithm”写成“算法”。
使用的是algorithm2e宏包,但是在使用SetAlgorithmName{Algorithm}{算法}{算法}时无法将算法的英文标题改成中文的。
捕获.PNG
代码如下所示:

\documentclass[11pt]{ctexbook}
\usepackage[ruled,vlined,algo2e,resetcount,algochapter]{algorithm2e}
\usepackage{algorithm}

\makeatletter
\renewcommand\thealgorithm{\thechapter.\arabic{algorithm}}
\@addtoreset{algorithm}{chapter}
\makeatother

\begin{document}
\chapter{测试算法章节}
引用算法\ref{Algorithm:算法框架}
\SetAlgorithmName{Algorithm}{算法}{算法}
\SetKwInput{KwIn}{输入}
\SetKwInput{KwOut}{输出}
\begin{algorithm}[!htb]
    \DontPrintSemicolon
    \hspace{-0.2em}\KwIn{最大迭代次数:$Gen_{max}$,种群规模:$N$ ,邻居大小:$T$\\
        \hspace{2.4em}最大调整向量数:$nus$
    }
    \hspace{-0.2em}\KwOut{种群$P$ }
    
    \caption{算法框架\label{Algorithm:算法框架}}
\end{algorithm}    
\end{document}

查看更多

关注者
1
被浏览
5.3k
逆天小白兔
逆天小白兔 2021-04-26
这家伙很懒,什么也没写!

algorithm2ealgorithm是两个不同的宏包,不能在一起使用

改用下面的就好了


\documentclass[11pt]{ctexbook}

\usepackage[ruled,vlined,algochapter]{algorithm2e}

\begin{document}
\chapter{测试算法章节}
引用算法\ref{Algorithm:算法框架}


\SetAlgorithmName{算法}{算法}{算法}
\SetKwInput{KwIn}{输入}
\SetKwInput{KwOut}{输出}

\begin{algorithm}
\DontPrintSemicolon

\KwIn{最大迭代次数:$Gen_{\max}$,种群规模:$N$ ,邻居大小:$T$\newline
最大调整向量数:$nus$
}

\KwOut{种群$P$ }

\caption{算法框架\label{Algorithm:算法框架}}
\end{algorithm}

\end{document}
2 个回答
zlter.w
zlter.w 2021-04-25
这家伙很懒,什么也没写!

看这里 https://www.latexstudio.net/index/details/index/mid/796.html

\renewcommand{\algorithmcfname}{算法}

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览