algpseudocode without end block text

Using the noend option as in

\usepackage[noend]{algpseudocode}

yields

enter image description here


Instead of (re)defining the way \While and \If works, you can remove the "end line" text via

\algtext*{EndWhile}% Remove "end while" text
\algtext*{EndIf}% Remove "end if" text

Here's your MWE:

enter image description here

\documentclass{article}
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
\algtext*{EndWhile}% Remove "end while" text
\algtext*{EndIf}% Remove "end if" text
\begin{document}

\begin{algorithmic}
\While{$n>3$}
   \If{$m>n$}
      \State ...
      \State ...
   \EndIf
   \If{$m>2$}
      \State ...
   \EndIf
\EndWhile
\end{algorithmic}

\end{document}​

You can say

\algdef{SxnE}[WHILE]{While}{EndWhile}[1]{\algorithmicwhile\ #1\ \algorithmicdo}
\algdef{SxnE}[IF]{If}{EndIf}[1]{\algorithmicif\ #1\ \algorithmicthen}
\algdef{cxnE}{IF}{Else}{EndIf}

Look for the \algdef lines in algpseudocode.sty for other constructs to modify.

The flag SxnE means that there's a "start line", but no "end line".

Tags:

Algorithmicx