[Tex/LaTex] break line in if condition using algpseudocode while having nice indentation


I am trying to split a long line in my algorithm, which is in my if condition into two lines, while maintaining indentation. AND I don't want the line break to be anywhere but after my -or- in the code.

SO here is my code




\caption{Core genome identification}
%I tired using this push
\While{$list$ is not empty \algorithmicor \\ \pushcode[1] second condition} 


I have tried it with this push for example, but this gives me a new line number what I don't want!

And other suggestions like defining


Also puts the indent on a spec. indentation, what is not what I am searching for. I want it to be at the same indentation as the condition before. So something like

if (this is my first condition OR
    this is the second)

Best Answer

Redefine the loop and if statements in the preamble (after \usepackage{algpseudocode}) as follows:

  {\algorithmicwhile\ \CONDITION{#1}{\ \algorithmicdo}}%
  {\algorithmicend\ \algorithmicwhile}
  {\algorithmicfor\ \CONDITION{#1}{\ \algorithmicdo}}%
  {\algorithmicend\ \algorithmicfor}
  {\algorithmicforall\ \CONDITION{#1}{\ \algorithmicdo}}
  {\algorithmicuntil\ \CONDITION{#1}{}}
  {\algorithmicif\ \CONDITION{#1}{\ \algorithmicthen}}%
  {\algorithmicend\ \algorithmicif}%
  {\algorithmicelse\ \algorithmicif\ \CONDITION{#1}{\ \algorithmicthen}}

The definitions are taken from the style file algpseudocode.sty and modified to handle multiline conditions.

Here is a complete example:


... Code from above ...

  \While{short condition} 
  \While{very long condition\\broken into two lines} 

enter image description here