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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to describe an algorithm, which is not changing a given input but it is producing a new element:

\documentclass[a4paper, 11pt]{scrbook}
\REQUIRE $\mathcal{P} \subset F[X_1 \dots X_{k-1 }][X_k]$
\ENSURE % something about the return value
\RETURN $\operatorname{Elim}_{X_k}(\mathcal{P})$

Ensure is not quite the thing I'm looking for because I want to make a statemanent about the output which does not have its own name.

Another thing is that I want to name the algorithm and lateron call it. I know that the algorithm does not to anthing different than call the function Elim but I want to underline the difference between the existence of a mathematical function and the algorithm (e.g. I don't want to discuss the computional complexity of a mathematical function).

Any ideas?

share|improve this question
While code snippets are useful in explanations, it is always best to compose a fully compilable MWE including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Nov 27 '11 at 18:04
up vote 3 down vote accepted

Note that there is no requirement to use the commands provided by the algorithms package - you can define your own.

In the minimal example below I've defined \OUTPUT which typesets Output: just like Ensure: and Require: (actually as an \item).

enter image description here

\usepackage{algorithmic}% http://ctan.org/pkg/algorithms
\usepackage{amsmath}% http://ctan.org/pkg/amsmath


\REQUIRE $\mathcal{P} \subset F[X_1 \dots X_{k-1 }][X_k]$
\OUTPUT Here is a statement about the output.
\RETURN $\operatorname{Elim}_{X_k}(\mathcal{P})$

I would suggest using the more advanced algorithmicx package. Or, for a more general view on alternatives to the above, see Print programs with its proper syntax.

share|improve this answer

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.