TeX - LaTeX Asked by Emanuele Nardi on April 5, 2021
I’m using the solution that @egreg provided on this answer, but I’m using the algorithm2e
package instead of algorithms
.
I’d like to retain the design from booktabs
but the command listofalgorithms
prints an empty list.
I think this is due to the fact that now the algorithms are figures, so the .loa
file results to be empty.
I don’t know how to proceed, any suggestion is appreciated.
This is my not working MWE
documentclass{book}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{algorithm2e}
usepackage{booktabs}
# https://tex.stackexchange.com/a/345745/127473
makeatletter
newcommandfs@booktabsruled{%
def@fs@cfont{bfseriesstrut}let@fs@captfloatc@ruled
def@fs@pre{hrule heightheavyrulewidth depth0pt kernbelowrulesep}%
def@fs@mid{kernaboverulesephrule heightlightrulewidthkernbelowrulesep}%
def@fs@post{kernaboverulesephrule heightheavyrulewidthrelax}%
let@fs@iftopcaptiftrue
}
makeatother
usepackage{float}
newfloat{algorithm}{h}{alg}
floatstyle{booktabsruled}
restylefloat{algorithm}
begin{document}
listofalgorithms % empty
begin{algorithm}
caption{test}
end{algorithm}
end{document}
The macros @fs@pre
, @fs@mid
, and @fs@post
from the post you linked have algorithm2e
counterparts called @algocf@pre@ruled
, algocf@caption@ruled
, @algocf@post@ruled
, so just use egreg's definitions for them. Algorithms from algorithm2e
are already floating and the package already takes care of the corresponding list-of.
documentclass{article}
usepackage[ruled]{algorithm2e}
usepackage{booktabs}
% Values shamelessly taken from egreg's answer in
% https://tex.stackexchange.com/a/345745/82917
makeatletter
renewcommand*{@algocf@pre@ruled}{hrule heightheavyrulewidth depth0pt kernbelowrulesep}
renewcommand*{algocf@caption@ruled}{boxalgocf@capboxkernaboverulesephrule heightlightrulewidthkernbelowrulesep}
renewcommand*{@algocf@post@ruled}{kernaboverulesephrule heightheavyrulewidthrelax}
makeatother
begin{document}
listofalgorithms
begin{algorithm}
While{condition}{
something;
}
caption{Some nice algorithm}
end{algorithm}
end{document}
(Huge screenshot, otherwise the rendering of the different rule thicknesses was bad.)
Correct answer by campa on April 5, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP