Why there is no 'end' in my For loop when I use algorithm2e package in Latex? [closed]

I am using the latex to write a Pseudo code about my algorithm,but there is no 'end' in my For loop when I use algorithm2e package?I use it like in the following way:

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

There is no 'end' for my for loop, does anyone know why?

latex pseudo code

1 Answer

With the vlined option you explicitly tell algorithm2e to replace the end with a vertical line. If you want an end, don't do that.

\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

You Might Also Like