4

Why if I write :

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

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

4

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

enter image description here

\documentclass{article}
\usepackage{amsmath,algpseudocode}% http://ctan.org/pkg/{amsmath,algorithmicx}
\algdef{SE}[EVENT]{Event}{EndEvent}[1]{\textbf{upon event}\ #1\ \algorithmicdo}{\algorithmicend\ \textbf{event}}%
\algtext*{EndEvent}
\begin{document}
\begin{algorithmic}[0]
  \Event{$< Init >$}
    \For{\textbf{all} $n \in N$}
      \State $\text{value}[r] = 0$;
    \EndFor
  \EndEvent
  \State Do something else;
\end{algorithmic}
\end{document}
3
  • OP, see also texdoc algorithmicx, the utility package algpseudocode is built with. Feb 26, 2014 at 17:20
  • 3
    $\langle\mathit{Init}\rangle}$
    – 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.