伪代码的latex代码
前言
由于实现伪代码排版的需求比较急,以下内容仅为个人观点,如有错误的地方,欢迎评论区留言~
公式部分推荐使用MathType,可直接转为latex代码。
algorithm+algorithmic
如果你的伪代码比较长,需要分页显示,个人体验就是不推荐使用algorithm2e工具包,因为这个工具包比较新,在使用手册中没有找到相关方法实现分页。(有实现的小伙伴欢迎评论区留言~
①基本用法
\caption{
Have a good time}\label{
algorithm} #算法名称
\renewcommand{
\algorithmicrequire}{
\textbf{
Input:}} #修改Require为Input
\renewcommand{
\algorithmicensure}{
\textbf{
Output:}} #修改Ensure为Output
\Require #Require
\Ensure #Ensure
\textbf{
text} #加粗文本
\bm{
equation} #加粗公式
$/*$ Comment $*/$ #/*加注释*/
for..to..do #for...to...do
while..do #while..then
if..then #if..then
②宏包(写在导言区,即 \begin{document} 之前)
\usepackage{
algorithm} #工具包
\usepackage[noend]{
algpseudocode} #工具包
\usepackage{
bm} #加