1

This question provides several good answers on creating custom algpseudocode blocks with no ending tag.

Based on that, I was wondering if such custom blocks can be redefined in order to detect the noend option, which for the standard blocks and loops makes their final indicator disappear.

Should it be done with a custom command tracking the existence of noend? Is there an internal flag inside algorithmicx that can be used?

I think it can have the following structure (not an actual solution, but a rough sketch):

\usepackage[noend]{algpseudocode}
\usepackage{ifthen}

\ifthenelse{\undefined{\noEndDetector}}{ % A command "sensing" the *noend* option
    \algdef[SE]{...} % Definition considering ending keywords
}{
    \algdef[SxNE]{...} % Definition without ending keywords
}

Any help is appreciated.

1

Well, after a bit of research it seems this question effectively answers my query.

As it turns out, there is a flag \ALG@noend that can be checked in order to determine if the option noend has been passed to the package.

Code snippet (taken from the question)

% Defines custom \On ... \EndOn block
\algnewcommand\algorithmicon{\textbf{on}}
\algnewcommand\algorithmicfrom{\textbf{from}}
\algblockdefx[ON]{On}{EndOn}[2]
  {\algorithmicon\ #1\ \algorithmicfrom\ #2\ \algorithmicdo}
  {\algorithmicend\ \algorithmicon}

% Tells algorithmicx not to print an empty line if `noend' is set 
\makeatletter
\ifthenelse{\equal{\ALG@noend}{t}}%
  {\algtext*{EndOn}}
  {}%
\makeatother

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.