I really like the vertical line feature of algorithm2e, but I ran into trouble with it when I try to indent an if statement. I used the following code.
\documentclass{article}
\usepackage{amssymb,amsthm,fullpage,amsmath}
\usepackage[ruled,vlined,boxed]{algorithm2e}
\begin{document}
\begin{algorithm}[H]
\caption{\bf Generic Line Search Algorithm}
{\bf Inputs:} Starting point $x_0$, initial step size parameter $\alpha_0$. \\
\For{$k = 0,1,2,\dots$}{
\nl {\bf Gradient approximation $g(x_k)$:}\\ \Indp
Compute an approximation $g(x_k)$ of $\nabla \phi(x_k)$. \\ \Indm
\nl {\bf Construct a search direction $d_k$:}\\ \Indp
Construct a search direction $d_k$, e.g., $d_k = - g(x_k)$.\\ \Indm
\nl {\bf Compute step size $\alpha_k$ and update the iterate:} \\ \Indp
\eIf{sufficient decrease condition is satisfied}{
$x_{k+1} = x_k - \alpha_k d_k$ and $\alpha_{k+1} \gets \tau^{-1} \alpha_k$
}{
$x_{k+1} = x_k$ and $\alpha_{k+1} \gets \tau \alpha_k$
}
}
\end{algorithm}
\end{document}
The texts were indented but the vertical lines in the if statement were not, as shown in the picture.
Does anyone know how to indent the vertical lines?
\vlined
and\Indp
do not work properly together. I will try to investigate this.