# How we can use [noend] only in some places in algorithms?

for example we have three nested loop

\FORALL{ condition 1}
\FORALL{condition 2}
\FORALL{condition 3}
\STATE {do sth}
\ENDFOR
\ENDFOR
\ENDFOR


if we use [noend] to be false then print 3 "endif" but I want to print only one, the first loop only!!

Does anybody has experiences?

-
Please add to your question a minimal, and compilable version of your code (including document class used, relevant packages involved, minimal example showing an algorithm). –  Gonzalo Medina Jun 27 '11 at 15:01
Welcome to TeX.sx! Please consider adding a minimal working example (MWE). –  Martin Scharrer Jun 27 '11 at 15:24

Seeing the syntax of your code snippet, I assume that you are using the algorithmic package. You should use the algorithmicx (with a trailing "x") instead; this package offers you many possibilities to customize the layout of algorithms and allows you to define a completely new layout for your specific needs.

In the following example code I show three variations on the same "algorithm"; the first one, shoes the standard behaviour (the three "forall-loops" with their corresponding "end for"). In the second one, I used \algnotext to suppress all the "end for" sentences. In the third one I used a custom-defined "forall" loop which doesn't produce any ending text; this, combined with the standard \ForAll, \EndFor construct, will produce the desired result:

\documentclass{article}
\usepackage{algorithmicx,algpseudocode}

\algloopdefx{NFor}[1]{\textbf{for all} #1 \textbf{do}}

\begin{document}

Each \texttt{for} with its corresponding ending:
\begin{algorithmic}
\ForAll{ condition 1}
\ForAll{condition 2}
\ForAll{condition 3}
\State{do sth}
\EndFor
\EndFor
\EndFor
\end{algorithmic}

Using \verb+\algnotext+ to suppress the ending part for every \verb+\EndFor+ command:
\begin{algorithmic}
\algnotext{EndFor}
\ForAll{ condition 1}
\ForAll{condition 2}
\ForAll{condition 3}
\State{do sth}
\EndFor
\EndFor
\EndFor
\end{algorithmic}

Using the newly defined loop-block to suppress the ending part at will:
\begin{algorithmic}
\ForAll{ condition 1}
\NFor{condition 2}
\NFor{condition 3}
\State{do sth}
\EndFor
\end{algorithmic}

\end{document}


-
But \algloopdefx is not compatible with "algorithmic" package! –  Mohammad Jun 30 '11 at 8:49