方式一

  • 需要包含的
\usepackage[noend]{algpseudocode}
\usepackage{algorithmicx,algorithm}
  • 源码
\begin{algorithm}[t]
\caption{algorithm caption} %算法的名字
\hspace*{0.02in} {\bf Input:} %算法的输入, \hspace*{0.02in}用来控制位置,同时利用 \\ 进行换行
input parameters A, B, C\\
\hspace*{0.02in} {\bf Output:} %算法的结果输出
output result
\begin{algorithmic}[1]
\State some description % \State 后写一般语句
\For{condition} % For 语句,需要和EndFor对应
  \State ...
  \If{condition} % If 语句,需要和EndIf对应
    \State ...
  \Else
    \State ...
  \EndIf
\EndFor
\While{condition} % While语句,需要和EndWhile对应
  \State ...
\EndWhile
\State \Return result
\end{algorithmic}
\end{algorithm}

注意

  1. 关键字的大小写问题,否则会出现 Undefined control sequence.
  2. 控制流要前后对应。如果有 While,但没有 EndWhile,否则会出现 Some blocks are not closed。

方式二

  • 需要包含的
\usepackage[ruled]{algorithm2e}
  • 源码
	\begin{algorithm}[H]
\caption{algorithm caption}%算法名字
\LinesNumbered %要求显示行号
\KwIn{input parameters A, B, C}%输入参数
\KwOut{output result}%输出
some description\; %\;用于换行
\For{condition}{
only if\;
\If{condition}{
1\;
}
}
\While{not at end of this document}{
if and else\;
\eIf{condition}{
1\;
}{
2\;
}
}
\ForEach{condition}{
\If{condition}{
1\;
}
}
\end{algorithm}

方式三

  • 需要包含的
\usepackage[ruled,vlined]{algorithm2e}
  • 源码
	\begin{algorithm}[H]
\caption{algorithm caption}%算法名字
\LinesNumbered %要求显示行号
\KwIn{input parameters A, B, C}%输入参数
\KwOut{output result}%输出
some description\; %\;用于换行
\For{condition}{
only if\;
\If{condition}{
1\;
}
}
\While{not at end of this document}{
if and else\;
\eIf{condition}{
1\;
}{
2\;
}
}
\ForEach{condition}{
\If{condition}{
1\;
}
}
\end{algorithm}

更多关于表格的信息,参考:

LaTeX算法排版 笔记的更多相关文章

  1. LaTeX算法排版

    需要包含的 \usepackage[noend]{algpseudocode} \usepackage{algorithmicx,algorithm} 源码 \begin{algorithm}[t]\ ...

  2. LaTeX 算法代码排版 --latex2e范例总结

    LaTeX 写作: 算法代码排版 --latex2e范例总结 latex2e 宏包的使用范例: \usepackage[ruled]{algorithm2e}                     ...

  3. Latex 算法Algorithm

    在计算机科学当中,论文当中经常需要排版算法.相信大家在读论文中也看见了很多排版精美的算法.本文就通过示例来简要介绍一下 algorithms 束的用法.该束主要提供了两个宏包,包含两种进行算法排版的环 ...

  4. C / C++算法学习笔记(8)-SHELL排序

    原始地址:C / C++算法学习笔记(8)-SHELL排序 基本思想 先取一个小于n的整数d1作为第一个增量(gap),把文件的全部记录分成d1个组.所有距离为dl的倍数的记录放在同一个组中.先在各组 ...

  5. Manacher算法学习笔记 | LeetCode#5

    Manacher算法学习笔记 DECLARATION 引用来源:https://www.cnblogs.com/grandyang/p/4475985.html CONTENT 用途:寻找一个字符串的 ...

  6. Latex 算法过长 分页显示方法

    参考: Algorithm tag and page break Latex 算法过长 分页显示方法 1.引用algorithm包: 2.在\begin{document}前加上以下Latex代码: ...

  7. 《Algorithms算法》笔记:元素排序(4)——凸包问题

    <Algorithms算法>笔记:元素排序(4)——凸包问题 Algorithms算法笔记元素排序4凸包问题 凸包问题 凸包问题的应用 凸包的几何性质 Graham 扫描算法 代码 凸包问 ...

  8. 《Algorithms算法》笔记:元素排序(3)——洗牌算法

    <Algorithms算法>笔记:元素排序(3)——洗牌算法 Algorithms算法笔记元素排序3洗牌算法 洗牌算法 排序洗牌 Knuth洗牌 Knuth洗牌代码 洗牌算法 洗牌的思想很 ...

  9. 《Algorithm算法》笔记:元素排序(2)——希尔排序

    <Algorithm算法>笔记:元素排序(2)——希尔排序 Algorithm算法笔记元素排序2希尔排序 希尔排序思想 为什么是插入排序 h的确定方法 希尔排序的特点 代码 有关排序的介绍 ...

随机推荐

  1. OpenCV---人脸检测

    一:相关依赖文件下载 https://github.com/opencv/opencv   二:实现步骤(图片检测) (一)读取图片 image= cv.imread("./d.png&qu ...

  2. 深入浅出CSS(二):关于雪碧图、background-position与steps函数的三角恋情

    [测试代码] HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset=&qu ...

  3. spring boot 2.0.3+spring cloud (Finchley)8、微服务监控Spring Boot Admin

    参考:Spring Boot Admin 2.0 上手 Spring Boot Admin 用于管理和监控一个或多个Spring Boot程序,在 Spring Boot Actuator 的基础上提 ...

  4. C语言实现栈(顺序存储方式)

    #include <stdio.h> #include <stdlib.h> //提供malloc()原型 #include <stdbool.h> //提供tru ...

  5. 2017ACM暑期多校联合训练 - Team 7 1002 HDU 6121 Build a tree (深搜+思维)

    题目链接 Problem Description HazelFan wants to build a rooted tree. The tree has n nodes labeled 0 to n− ...

  6. zedboard学习记录.3.oled,创建IP

    环境:win7 .vivado 2017.4 .zedboard rev.d 首先建立工程. 1.Tools -> Create and Package New IP 2.Create AXI4 ...

  7. zedboard学习记录.2.PS+PL 流水灯与uart

    1.建立一个工程. 硬件设计 2.IP integrator -> create block desgin;Run Block Automation. 3.add IP -> AXI GP ...

  8. 蓝色的cms网站后台管理模板——后台

    链接:http://pan.baidu.com/s/1c138cwC 密码:9vy9

  9. React Native 与 夜神模拟器的绑定

    之前一直用真机去调试, 每回更新一次都需要手动摇晃手机后才能reload JS, OMG,太麻烦了. 后来寻思模拟器网上推荐用Geny...什么的模拟器,但是那个模拟器还需要VBox一起用. 有点麻烦 ...

  10. memcached安装【转】

    1.安装依赖软件 # yum -y install libevent libevent-devel perl-Test-Harness perl-Time-HiRes perl-TermReadKey ...