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.

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

share|improve this question

1 Answer 1

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}
share|improve this answer
    
OP, see also texdoc algorithmicx, the utility package algpseudocode is built with. –  Sean Allred Feb 26 at 17:20
2  
$\langle\mathit{Init}\rangle}$ –  egreg Feb 26 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! –  user1938352 Feb 26 at 17:40

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.