4

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} 
11

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}.

2
  • It's working perfectly! Thanks a ton. Should I be setting up some sort of macro for \textbf{Begin}?
    – Jeel Shah
    Apr 23 '13 at 0:58
  • 1
    @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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.