# How call several commands by one commands?

If you want to write an algorithm, you have to write three commands to initialize a writing environment.

\usepackage{algorithm}
\usepackage[noend]{algpseudocode}

\begin{algorithm} % no.1
\begin{algorithmic} % no.2
\Procedure{Sum}{100} % no.3
\State abcd
\EndProcedure
\end{algorithmic}
\end{algorithm}


And write three lines to end it. So is there any way to wrap it up, using one command to simplify it?

-

You can define a myalgorithm environment (you can call it anything you want) that does this. If you add

\newenvironment{myalgorithm}[2]
{\begin{algorithm}\begin{algorithmic}\Procedure{#1}{#2}}
{\EndProcedure\end{algorithmic}\end{algorithm}}


you can use this in your document as

\begin{myalgorithm}{Sum}{100}
\State abcd
\end{myalgorithm}


The two arguments are those that are given to the \Procedure command. Note that this will not allow you to add a caption or label to the algorithm floating environment.

-
Thank you for that. \end{myalgorithm} in the end. –  Peter Jul 13 '14 at 5:44