如何在论文中展示算法
我们推荐使用 lovelace 来书写伪代码,主要使用提供的 pseudocode-list 函数
在我们的模板中,用法如下:
1#import "@preview/lovelace:0.3.0": line-label, pseudocode-list2//3
4#figure(5 kind: "algorithm",6 pseudocode-list(7 indentation: 1em,8 hooks: .5em,9 booktabs: true,10 title: [*@alg:cdcl-algo:*CDCL 算法],11 )[12 - *输入:* 一个 CNF 公式13 - *输出:* 结果 UNSAT 或 SAT,表示公式是否可满足14 + *while* _true_ *do*15 + conf $arrow.l$ _bcp_()16 + *if* conf $eq.not emptyset$ *then*17 + bl $arrow.l$ *analyze*(conf)18 + *if* bl $lt 0$ *then* *return* UNSAT19 + _brackjump_(bl)20 + *else*21 + v $arrow.l$ _decide_()22 + *if* v $eq 0$ *then return* SAT23 ],24 caption: [CDCL 算法框架伪代码],25)<cdcl-algo>其效果如下图所示:

正如上文所示,我们通过 @alg:cdcl-algo 来引用这个伪代码,根据标签的不同,只需要在标签前加上 alg: 即可(这是在我们模板内嵌入的)