LaTeX算法排版 笔记
方式一
- 需要包含的
\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}
注意:
- 关键字的大小写问题,否则会出现 Undefined control sequence.
- 控制流要前后对应。如果有 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算法排版 笔记的更多相关文章
- LaTeX算法排版
需要包含的 \usepackage[noend]{algpseudocode} \usepackage{algorithmicx,algorithm} 源码 \begin{algorithm}[t]\ ...
- LaTeX 算法代码排版 --latex2e范例总结
LaTeX 写作: 算法代码排版 --latex2e范例总结 latex2e 宏包的使用范例: \usepackage[ruled]{algorithm2e} ...
- Latex 算法Algorithm
在计算机科学当中,论文当中经常需要排版算法.相信大家在读论文中也看见了很多排版精美的算法.本文就通过示例来简要介绍一下 algorithms 束的用法.该束主要提供了两个宏包,包含两种进行算法排版的环 ...
- C / C++算法学习笔记(8)-SHELL排序
原始地址:C / C++算法学习笔记(8)-SHELL排序 基本思想 先取一个小于n的整数d1作为第一个增量(gap),把文件的全部记录分成d1个组.所有距离为dl的倍数的记录放在同一个组中.先在各组 ...
- Manacher算法学习笔记 | LeetCode#5
Manacher算法学习笔记 DECLARATION 引用来源:https://www.cnblogs.com/grandyang/p/4475985.html CONTENT 用途:寻找一个字符串的 ...
- Latex 算法过长 分页显示方法
参考: Algorithm tag and page break Latex 算法过长 分页显示方法 1.引用algorithm包: 2.在\begin{document}前加上以下Latex代码: ...
- 《Algorithms算法》笔记:元素排序(4)——凸包问题
<Algorithms算法>笔记:元素排序(4)——凸包问题 Algorithms算法笔记元素排序4凸包问题 凸包问题 凸包问题的应用 凸包的几何性质 Graham 扫描算法 代码 凸包问 ...
- 《Algorithms算法》笔记:元素排序(3)——洗牌算法
<Algorithms算法>笔记:元素排序(3)——洗牌算法 Algorithms算法笔记元素排序3洗牌算法 洗牌算法 排序洗牌 Knuth洗牌 Knuth洗牌代码 洗牌算法 洗牌的思想很 ...
- 《Algorithm算法》笔记:元素排序(2)——希尔排序
<Algorithm算法>笔记:元素排序(2)——希尔排序 Algorithm算法笔记元素排序2希尔排序 希尔排序思想 为什么是插入排序 h的确定方法 希尔排序的特点 代码 有关排序的介绍 ...
随机推荐
- sqlserver 2008备份与还原
一.SQL数据库的备份: 1.依次打开 开始菜单 → 程序 → Microsoft SQL Server 2008 → SQL Server Management Studio → 数据库:Dside ...
- [LeetCode] 30. Substring with Concatenation of All Words ☆☆☆
You are given a string, s, and a list of words, words, that are all of the same length. Find all sta ...
- UndertowServer+SpringMVC+Thymeleaf模板引擎构建轻量级的web项目
这两周需要写一个页面来请求另一个服务中的接口,服务器采用了超轻量级的undertow,模板引擎采用的是Thymeleaf,在寻找页面资源位置这个地方难住了我.下面分享一下,这方面的代码. Spring ...
- JAVA 日期处理工具类 DateUtils
package com.genlot.common.utils; import java.sql.Timestamp;import java.text.ParseException;import ja ...
- UVA 11982 Fantasy Cricket
https://vjudge.net/problem/UVA-11982 题意: 给出一个包含’U’, ‘D’, ‘E’的字符串, ’U’ 表示需要把这个字符向后移动, ’D’表示需要把这个字符向前移 ...
- C#为何不推荐在构造函数中访问虚成员
如果在一个类中定义了虚属性或者虚方法,又在构造函数中访问了这个虚属性或方法,此时VisualStudio是不会给出警告,并且编译也没有问题,但是如果安装了Resharper插件则会给出警告提示:&qu ...
- 【CodeForces】915 F. Imbalance Value of a Tree 并查集
[题目]F. Imbalance Value of a Tree [题意]给定n个点的带点权树,求所有路径极差的和.n,ai<=10^6 [算法]并查集 [题解]先计算最大值的和,按点权从小到大 ...
- jquery实现简单轮播
先上简单的html代码 <!DOCTYPE HTML> <html> <head> <link rel="stylesheet" type ...
- bzoj 1072 状压DP
我们用w[i][j]来表示,i是一个二进制表示我们选取了s中的某些位,j表示这些位%d为j,w[i][j]则表示这样情况下的方案数,那么我们可以得到转移.w[i|(1<<k)][(j*10 ...
- Git HTTPS 方式自动保存用户名密码
一行命令搞定: git config --global credential.helper wincred 第一次输入用户名和密码提交,第二次就不需要了 参考: https://help.github ...