latex加入算法块

  1. 加入要用的包
latex 复制代码
\usepackage[ruled]{algorithm2e}
  1. 定义代码块

    \begin{algorithm}[htb]
    \caption{This is a Example}
    \label{alg:example}
    \LinesNumbered
    \KwIn{A set of Points}
    \KwOut{A triangle mesh}
    Begin your Algorithm
    ......
    如果在一个代码块里想要换行的时候,在每一行的结尾加上;
    ......
    End your Algorithm
    \end{algorithm}

  2. 使用While

    \While{condition of judgment}{
    operation to be performed
    }

  3. 使用if......else

    \If{condition of judgment}{
    operation to be performed
    }
    \Else{
    operation to be performed
    }

  • 除了\If, \Else, \ElseIf之外,还有\uIf, \lIf, \uElse, \lElse, \uElseIf, \lElseIf等命令,他们的区别在于
    \If, \Else, \ElseIf都是会以end结尾
  • \uIf, \uElse, \uElseIf, 是不以end结尾的块级元素
  • \lIf, \lElse, \lElseIf 是不以end为结尾的行内元素
  • 在If-else结构中,\eIf 自带else(即 if 和 else 共用一个 end),而只是用 \If 和 \Else 的话则会多出一个end给Else。

Reference

https://www.cnblogs.com/X1OO/articles/17025753.html

https://blog.csdn.net/Bule_Zst/article/details/88848102

https://oldtang.com/8376.html

https://www.ctan.org/pkg/algorithm2e

https://mirrors.ustc.edu.cn/CTAN/macros/latex/contrib/algorithm2e/doc/algorithm2e.pdf

https://zhuanlan.zhihu.com/p/166418214

相关推荐
伟贤AI之路2 天前
为什么AI里的公式复制到Word格式会乱?
人工智能·word·latex
weixin_416660073 天前
从标记语言到 Word 文档:AI 生成的 Mermaid 与 LaTeX 自动化转换的技术方案解析
word·latex·数学公式·deepseek
记录无知岁月9 天前
【LaTeX】入门和使用拾遗
数学建模·教程·latex·论文写作·texlive·texsudio
微小冷10 天前
用Latex画思维导图:Forest
latex·思维导图·脑图·tikz·forest·树形图
热爱生活的五柒21 天前
如何将word中latex公式复制到另一个文档中
word·latex
Sakuraba Ema23 天前
从零理解 MoE(Mixture of Experts)混合专家:原理、数学、稀疏性、专家数量影响与手写 PyTorch 实现
人工智能·pytorch·python·深度学习·数学·llm·latex
简宸~24 天前
VS Code + LaTex + SumatraPDF联合使用指南
java·vscode·latex·sumatrapdf
bu_shuo1 个月前
AI生成的数学公式复制为LaTeX插件
ai·chatgpt·latex·gemini·千问·豆包·数学公式复制
还不秃顶的计科生1 个月前
latex代码裁剪pdf图片
pdf·latex
小哈里2 个月前
【科研】ACM MM 论文 Latex 投稿模板修改(基于sample-sigconf-authordraft-v2.16)
人工智能·llm·科研·latex·cv·overleaf