TeX - LaTeX Asked on October 5, 2021
I’m having this code
documentclass[11pt,a4paper]{article}
usepackage[]{algorithm2e}
begin{document}
begin{algorithm}[H]
If{cond}{
stmt1;
}
end{algorithm}
end{document}
This makes some algorithms much shorter, I’m searching for a way to get rid of the newline after the then
(for ifs
where the body is only a oneliner). Is this possible with algorithm2e
and if yes how?
For a one line if-statement you can use lIf
(line if). The semicolon is added automatically.
documentclass[11pt,a4paper]{article}
usepackage{algorithm2e}
begin{document}
begin{algorithm}
If{cond}{
stmt1;
}
lIf{cond}{
stmt2
}
other things
end{algorithm}
end{document}
See page 32 of the package manual for the different macros for if-then-else constructs.
Correct answer by Marijn on October 5, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP