[tip] LaTeX的中文算法跨页
·
LaTeX的中文算法跨页
之前一直使用的是\floatname{algorithm}{算法}来实现中文算法名称的替换。
但是当因算法过长,使用了算法跨页时,发现这个方法不起作用。
在仔细研究之后发现其实很简单,在\makeatletter和\makeatother之间的定义中添加\renewcommand{\ALG@name}{算法}即可,例如:
%算法跨页
\makeatletter
\renewcommand{\ALG@name}{算法} %中文名称替代
\newenvironment{breakablealgorithm}
{% \begin{breakablealgorithm}
\begin{flushleft}
\refstepcounter{algorithm}% New algorithm
\hrule height.8pt depth0pt \kern2pt% \@fs@pre for \@fs@ruled
\renewcommand{\caption}[2][\relax]{% Make a new \caption
{\raggedright\textbf{\ALG@name~\thealgorithm} ##2\par}%
\ifx\relax##1\relax % #1 is \relax
\addcontentsline{loa}{algorithm}{\protect\numberline{\thealgorithm}##2}%
\else % #1 is not \relax
\addcontentsline{loa}{algorithm}{\protect\numberline{\thealgorithm}##1}%
\fi
\kern2pt\hrule\kern2pt
}
}{% \end{breakablealgorithm}
\kern2pt\hrule\relax% \@fs@post for \@fs@ruled
\end{flushleft}
}
\makeatother
\floatname{Algorithm}{算法}
即可实现中文跨页算法。
更多推荐



所有评论(0)