# Using algorithm2e, how to make IF condition 1 OR conditions 2 OR conditions 3 THEN

Using algorithm2e currently when I do this

\If{ condition_1  OR condition_2 OR condition_3}

But if the stuff between {} is too long, it wraps around and does not look good since there is no alignment.

I looked at Multiple conditions in a "If" algorithm but did not see a solution there.

Is there a way to break each condition on its line, so it show up at end as follows

IF condition_1
OR
condition_2
OR
condition_3  THEN
....
END IF

Here is a MWE, showing 2 conditions only as an example.

\documentclass{article}
\usepackage{amsmath,amssymb}

\usepackage{algorithmic}
\usepackage[linesnumbered,ruled]{algorithm2e}

\begin{document}
\begin{algorithm}
\DontPrintSemicolon

\KwIn{1st order ODE}
\KwOut{solution}

\eIf{ A}
{
stuff
\eIf{  B}
{
stuff
}
{
\uIf{ condition 1  \textbf{or} condition 2  \textbf{or}  condition 3 }
{
stuff
}
\uElseIf{ condition 1  \textbf{and} condition 2 \textbf{and} condition 3 }
{
stuff
}
\ElseIf{  condition 1  \textbf{or} condition 2 \textbf{and} condition 3  }
{
stuff
}
}
}
{
stuff
}
\Return solution

\caption{my algorithm}

\end{algorithm}

\end{document}

Compiled using lualatex, this is the output

btw, I could not find \Or , \And in algorithm2e so I am for now using \textbf{or} in place.

## Trials

Tried manual fix, which almost works, like this

\documentclass{article}
\usepackage{amsmath,amssymb}

\usepackage{algorithmic}
\usepackage[linesnumbered,ruled]{algorithm2e}

\begin{document}
\begin{algorithm}
\DontPrintSemicolon

\KwIn{1st order ODE}
\KwOut{solution}

\eIf{ A}
{
stuff
\eIf{  B}
{
stuff
}
{
\uIf{ condition 1 \;
\hspace{30pt}\textbf{or}\;
\hspace{15pt} condition 2\;
\hspace{30pt}\textbf{or}\;
\hspace{15pt}condition 3 }
{
stuff
}
\uElseIf{ condition 1  \textbf{and} condition 2 \textbf{and} condition 3 }
{
stuff
}
\ElseIf{  condition 1  \textbf{or} condition 2 \textbf{and} condition 3  }
{
stuff
}
}
}
{
stuff
}
\Return solution
\caption{my algorithm}
\end{algorithm}
\end{document}

Which now looks like

The vertical lines ruled now do not look good as not have gaps.

Any better solution to this? I could ofcourse just turn off the vertical lines using \SetAlgoNoLine and now it looks OK. But it is nice to have the vertical lines there if possible.

TL 2020

I am not familiar with algorithm2e enough, hence the following approach is not perfect. This attempt uses the macros in algorithm2e documentation, sec. 11.

### Small example

\documentclass{article}
\usepackage{amsmath,amssymb}

\usepackage{algorithmic}
\usepackage[linesnumbered]{algorithm2e}

\begin{document}

\SetKw{Or}{\hspace{\algoskipindent}\itshape or\;}
\SetKw{And}{\hspace{\algoskipindent}\itshape and\;}
\SetKwBlock{Condition}{}{}

\begin{algorithm}
\DontPrintSemicolon
\If{condition 1 \Condition{\Or condition 2 \;\Or condition 3 \;\And condition 4}}
{
stuff
}
\end{algorithm}

\end{document}

\documentclass{article}
\usepackage{amsmath,amssymb}

\usepackage{algorithmic}
\usepackage[linesnumbered,ruled]{algorithm2e}

\SetKw{Or}{\hspace{\algoskipindent}\itshape or\;}
\SetKw{And}{\hspace{\algoskipindent}\itshape and\;}
\SetKwBlock{Condition}{}{}

\begin{document}
\begin{algorithm}
\DontPrintSemicolon

\KwIn{1st order ODE}
\KwOut{solution}

\eIf{ A}
{
stuff
\eIf{  B}
{
stuff
}
{
\uIf{condition 1 \Condition{\Or condition 2 \;\Or condition 3}}
{
stuff
}
\uElseIf( // the indent is not satisfying){condition 1 \Condition{\And condition 2 \;\And condition 3}}
{
stuff
}
\ElseIf{\Condition{condition 1  \;\Or condition 2 \;\And condition 3}}
{
stuff
}
}
}
{
stuff
}
\Return solution

\caption{my algorithm}
\end{algorithm}

\end{document}