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
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{algorithm}
\usepackage{algpseudocode}
\algnewcommand\algorithmicor{\textbf{or}}
\newcommand{\pushcode}[1][1]{\hskip\dimexpr#1\algorithmicindent\relax}
\begin{algorithm}[h]
\caption{Core genome identification}
\begin{algorithmic}[1]
%I tired using this push
\While{$list$ is not empty \algorithmicor \\ \pushcode[1] second condition}
\EndWhile
\end{algorithmic}
\end{algorithm}
\end{document}
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
\newcommand{\myindent}[1]{
\newline\makebox[#1]{}
}
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:The definitions are taken from the style file
algpseudocode.sty
and modified to handle multiline conditions.Here is a complete example:
... Code from above ...