2

I am using this approach to have a for all ... do in parallel using the algcompatible package.

\documentclass{article}
\usepackage{algorithm}
\usepackage{algcompatible}

\algblockdefx{FORALLP}{ENDFAP}[1]%
  {\textbf{for all }#1 \textbf{do in parallel}}%
  {\textbf{end for}}

\begin{document}

\begin{algorithm}
\caption{A test algorithm}
\begin{algorithmic}[1]
\FORALL {$v \in V(G)$}
\STATE $l(v) \leftarrow \infty$
\ENDFOR
\FORALLP{$v \in V(G)$}
\STATE $l(v) \leftarrow \infty$
\ENDFAP
\end{algorithmic}
\end{algorithm}

\end{document}

How can I get rid of the end for at the end of the block?

  • I've added a MWE – Filippo Bistaffa Jan 31 '15 at 18:19
  • You probably want to remove also the “end for” in the \FORALL cycle. Note that algcompatible is just for old documents and algpseudocode should be used instead. – egreg Jan 31 '15 at 18:22
  • 1
    Use \algtext*{ENDFAP} after defining FORALLP and ENDFAP, as suggested in algpseudocode without end block text. – Werner Jan 31 '15 at 18:25
  • @FilippoBistaffa: Since the answer is entirely contained in the linked post, this could be considered a duplicate (rather up-vote the linked posts). – Werner Jan 31 '15 at 19:11

Browse other questions tagged or ask your own question.