# Implementing indent in algorithm environment

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}


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}


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

• It's working perfectly! Thanks a ton. Should I be setting up some sort of macro for \textbf{Begin}? Apr 23 '13 at 0:58
• @gekkostate yes. Perhaps one of the built-in mechanisms that the package offers for defining structures could help you. Apr 23 '13 at 2:12