0

While writing down an algorithm, I've come to the following construct:

enter image description here

There are multiple for/if/while's before this one so it is quite indented.

Example code:

\usepackage{algpseudocode,algorithm,algorithmicx}
\begin{document}
\begin{algorithm}
\begin{algorithmic}[1]
\If{true}
\If{$interval.start - error_{early} \leq timestamp + error_{late}$ {\bf and} $timestamp - error_{early} \leq interval.end + error_{late}$}
\State \Return{$false$}
\EndIf
\EndIf
\end{algorithmic}
\end{algorithm}
\end{document}

The If line is too long an I would like to break the line before or after the and. Linebreaking with \\ does not work.

  • From the proposed duplicate, particularly this answer: \par\hskip\algorithmicindent {\bf and} with indentation or \par\hskip -2mm {\bf and} without. Note that \bf is deprecated, you should use \textbf{and} or {\bfseries and} (see for example texfaq.org/FAQ-2letterfontcmd). – Marijn Sep 26 '19 at 16:12
  • Thanks, works very nicely. I used multiple \hskip\algorithmicindent and then 1mm for what was left. – sollniss Sep 26 '19 at 16:23