TeX - LaTeX Asked by onlycparra on December 18, 2020
I need to get something like this:
But I’m getting this (note the vertical line):
Here my code:
documentclass{report}
usepackage[linesnumbered,ruled,vlined,spanish,onelanguage]{algorithm2e}
begin{document}
begin{algorithm}
caption{SomeTitle}
label{alg:classes}
DontPrintSemicolon
SetAlgoLined
footnotesize
delRef(Refutation ref){;
Indp
Lanza Hilo que borra refutaciones en esta parte;
If{se eliminaron refutaciones}{
synczd $leftarrow$ false;
actualizar size;
}
Indm
};
end{algorithm}
end{document}
I have checked this documentation but I can’t find how to draw those lines after the Indp
As always, thank you so much for your time 🙂
This answer is quite similar to This answer. The indp
and indm
are not good friends of vlined
. What you could do if you wanted to indent is add a new (in this case empty) block using
SetKwBlock{DummyBlock}{}{}
As in the previous answer, this would give the new dummy block a vertical line which can easily be removed with SetAlgoNoLine
. Then we set in the block `SetAlgoLined' To have the vertical line on the If.
MWE:
documentclass{report}
usepackage[linesnumbered,ruled,vlined,spanish,onelanguage]{algorithm2e}
SetKwBlock{DummyBlock}{}{}
begin{document}
begin{algorithm}
caption{With Dummy}
label{alg:classes}
DontPrintSemicolon
SetAlgoLined
footnotesize
delRef(Refutation ref){
SetAlgoNoLineDummyBlock{SetAlgoLined
Lanza Hilo que borra refutaciones en esta parte;
If{se eliminaron refutaciones}{
synczd $leftarrow$ false;
actualizar size;
}}
};
end{algorithm}
end{document}
Notice here that the use of ;
is important: it tells algorithm2e
when to go down a new line. The Dummy block already feeds one line down so we can remove the ;
at the end of line 1.
An even better solution would be to insert line 1 into a block:
documentclass{report}
usepackage[linesnumbered,ruled,vlined,spanish,onelanguage]{algorithm2e}
SetKwBlock{delRef}{delRef(Refutation ref){}{}}
begin{document}
begin{algorithm}
caption{With new Block}
label{alg:classes}
DontPrintSemicolon
SetAlgoLined
footnotesize
SetAlgoNoLinedelRef{SetAlgoLined
Lanza Hilo que borra refutaciones en esta parte;
If{se eliminaron refutaciones}{
synczd $leftarrow$ false;
actualizar size;
}}
end{algorithm}
end{document}
I was assuming this was not what you were looking for.
Answered by Elad Den on December 18, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP