[Tex/LaTex] Implementing indent in algorithm environment

algorithm2ealgorithmsindentation

I am using the algorithm environment in the algorithm2e package. What I want is to able to indent various portions. I tried \indent but that is doing me no good. Here is the MWE:

\documentclass[12pt,letterpaper]{article}
\usepackage{algorithm2e}
\begin{algorithm}[H]
\SetAlgoLined

\KwData{Executor class}
\KwResult{Executes Main.java} 

    \indent \textbf{Begin} Executor class

    \indent call Main

    \indent \textbf{End} Executor class

\end{algorithm}

\end{document} 

Best Answer

You can use \Indp (the reverse effect can be achieved with \Indm):

\documentclass[12pt,letterpaper]{article}
\usepackage{algorithm2e}

\begin{document}

\begin{algorithm}[H]
\SetAlgoLined
\KwData{Executor class}
\KwResult{Executes Main.java} 
\Indp\textbf{Begin} Executor class \\
call Main \\
\textbf{End} Executor class
\end{algorithm}

\end{document} 

enter image description here

Perhaps you should consider defining some structure to avoid manually writing \textbf{Begin}, \textbf{End}.

Related Question