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.

I have the following chunk of code

\begin{algorithmic}
\State $\mathit{FlatMask}(c)=0$
\If{$\mathit{Inc1}(c)>0$}
    \State $\mathit{FlatMask}(c)\;+\!\!=2(\mathit{Inc1}(c)-1)$
\EndIf
\end{algorithmic}

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?

share|improve this question
    
Please, embed the code in a MWE. –  egreg Apr 3 '12 at 21:28
    
Great space-saver for papers ! –  johntex Apr 20 at 5:55
add comment

2 Answers 2

up vote 4 down vote accepted

The following is a simple method to do this:

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

An expanded answer is available here.

share|improve this answer
add comment

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

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

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

share|improve this answer
add comment

Your Answer

 
discard

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.