Why if I write :

\State \textbf{upon event $< Init >$  do}
        \For{\textbf{all $n$} $\in N$}
            \State $value[r]=0$;

I have this output:

enter image description here but I want:

enter image description here How can I do it?Thankyou very much

1 Answer 1


You can define a new block structure \Event...\EndEvent to suit your needs:

enter image description here

\usepackage{amsmath,algpseudocode}% http://ctan.org/pkg/{amsmath,algorithmicx}
\algdef{SE}[EVENT]{Event}{EndEvent}[1]{\textbf{upon event}\ #1\ \algorithmicdo}{\algorithmicend\ \textbf{event}}%
  \Event{$< Init >$}
    \For{\textbf{all} $n \in N$}
      \State $\text{value}[r] = 0$;
  \State Do something else;
  • OP, see also texdoc algorithmicx, the utility package algpseudocode is built with. Feb 26, 2014 at 17:20
  • 3
    – egreg
    Feb 26, 2014 at 17:27
  • thank you very much. I added \algdef{SE}[EVENT]{Event}{EndEvent}[1]{\textbf{upon event}\ #1\ \algorithmicdo}{\algorithmicend\ \textbf{event}}% \algtext*{EndEvent} and everything works! Feb 26, 2014 at 17:40

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.