Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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


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

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

share|improve this question

1 Answer 1

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


you can use this in your document as

  \State abcd

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.

share|improve this answer
Thank you for that. \end{myalgorithm} in the end. –  Peter Jul 13 '14 at 5:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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