I am trying to write the algorithm shown in the picture
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".
Asked
Active
Viewed 231 times
0
egreg
- 1,121,712
-
1Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Sep 20 '22 at 06:48
-
1For an overview of algorithm packages see: algorithm, algorithmic, algorithmicx, algorithm2e, algpseudocode = confused. – dexteritas Sep 20 '22 at 11:02
-
it is a good overview, but I still cannot figure it out how to write "if not (condition)"! – Yaaqob Saad Sep 21 '22 at 06:42
-
1Even if you couldn't figure out how to write "if not (condition)", it would have been nice for you to create a MWE with the rest of it. And for the question to be answerable, you would have needed to pick from one of the 5 algorithm packages mentioned. – Teepeemm Nov 09 '23 at 19:19
1 Answers
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}
samcarter_is_at_topanswers.xyz
- 158,329
user615536
- 165
-
3Given 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
-
1As 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
-
2Sorry, 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
