latex - 当我在Latex中使用algorithm2e包时,为什么我的For循环中没有 'end'?

标签 latex

我正在使用 latex 编写关于我的算法的伪代码,但是当我使用algorithm2e包时,我的For循环中没有“结束”?我按以下方式使用它:

\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\begin{algorithm}[t]
\For{$k=1$ \KwTo $n$}
{   
$P=A*P*A^{T}$
}
\end{algorithm}

我的 for 循环没有“结束”,有人知道为什么吗?

latex pseudo code

最佳答案

使用vlined选项,您可以明确告诉algorithm2e用垂直线替换end。如果您想要结束,请不要这样做。

\documentclass{article}

\usepackage[linesnumbered,ruled,lined]{algorithm2e}

\begin{document}

\begin{algorithm}[t]
\For{$k=1$ \KwTo $n$}
{   
$P=A*P*A^{T}$
}
\end{algorithm}

\end{document}

enter image description here

关于latex - 当我在Latex中使用algorithm2e包时,为什么我的For循环中没有 'end'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66429949/

相关文章:

pdf - pdfLaTeX 中的首字下沉

javascript - 如何在 Javascript 中重写 RegExp?

python - 使用 Vim 的 syn-include 和 syn-region 嵌入语法高亮时出现问题

使用 xtable 时删除 data.frame 行名称

git - 使用TeXLive 2017和latexml构建docker镜像

r - 使用 Sweave 编写大型文档。可以像 LaTeX 那样做吗?

latex - Latex Beamer 中的开关覆盖规范

python - 如何在 latexpdf 输出中使用 Sphinx 获取列表周围的间距?

r - 有什么方法可以从lme4 mer模型拟合对象生成LaTeX表?

html - 如何最好地编写针对 HTML 和 PDF 的文档?