0

I am trying to write the algorithm shown in the picture 1 in latex but I cannot know which package suitable for it either algorithm, or algorithm2e. Beside that the flow itself, I do not know how to write the condition "if not".

egreg
  • 1,121,712

1 Answers1

4

I don't know much about this, but you could try

\documentclass[]{article}

\usepackage[ruled]{algorithm2e} % remove [ruled] if you like \SetKwIF{IfNot}{ElseIfNot}{}{if not}{then}{else if not}{}{}

\begin{document} \begin{algorithm} \caption{An algorithm} \lIfNot{...}{...} \lIf{...}{...}

\uIfNot{A}{ ...; }\uElseIf{B}{ ...; }\uElseIfNot{B}{ ...; }\Else{ ...; } \end{algorithm} \end{document}

enter image description here

  • 3
    Given the multitude of algorithm packages, it would be nice if you would show a short, but compilable document in your answer so people can see which packages etc. you use. – samcarter_is_at_topanswers.xyz Nov 08 '23 at 12:58
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. – Community Nov 08 '23 at 13:11
  • 2
    Sorry, I misread the question as being specific about algorithm2e. I have now edited my answer to be compilable. It's only requirement is the algorithm2e package – user615536 Nov 09 '23 at 17:36