I have the following chunk of code

\State $\mathit{FlatMask}(c)=0$
    \State $\mathit{FlatMask}(c)\;+\!\!=2(\mathit{Inc1}(c)-1)$

It displays using the algpseudocode package, but I would like that the final printed End If not be displayed, just the indentation to be reset.

Any thoughts?

  • Please, embed the code in a MWE. – egreg Apr 3 '12 at 21:28
  • Great space-saver for papers ! – Ioannis Filippidis Apr 20 '14 at 5:55

The following is a simple method to do this:

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

An expanded answer is available here.


In this instance it is easy enough to define a new loop, since they do not require an accompanying ending macro:

enter image description here

\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
\algloopdefx{NoEndIf}[1]{\textbf{If} #1 \textbf{then}}
\State $\mathit{FlatMask}(c)=0$
    \State $\mathit{FlatMask}(c)\;+\!\!=2(\mathit{Inc1}(c)-1)$
\State Some code

In the above example, \NoEndIF is the newly-defined "loop" structure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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