TransWikia.com

How to include multiple label in algorithm2e and adjust numbering in a specific way?

TeX - LaTeX Asked on August 12, 2021

Suppose I have the following LaTeX source:

documentclass[letterpaper,12pt]{article}
pagestyle{myheadings}


%----------------------------------------------------------
% algorithm2e setup
usepackage{xcolor}
usepackage[linesnumbered,ruled,vlined, nofillcomment, algosection]{algorithm2e}

%%% Coloring the comment as blue
newcommandmycommfont[1]{footnotesizettfamilytextcolor{blue}{#1}}
SetCommentSty{mycommfont}

SetKwInput{KwInput}{Input}                % Set the Input
SetKwInput{KwOutput}{Output}          % set the Output
SetKwInput{KwGlobalVariable}{Global variables}
SetKw{Continue}{continue}
% end of algorithm2e setup
%----------------------------------------------------------

begin{document}



section{Algroithm Idea group 1}label{sec:introduction}

begin{algorithm}[h]
    foo
    caption{part of my algorithm Idea group 1 and also shared with group 2}
end{algorithm}

begin{algorithm}[h]
    foo
    caption{part of my algorithm Idea group 1}
end{algorithm}

section{Algroithm Idea group 2}

begin{algorithm}[h]
    bar
    caption{part of my algorithm Idea group 2}
end{algorithm}

begin{algorithm}[h]
    bar
    caption{part of my algorithm Idea group 2}
end{algorithm}

end{document}
endinput

Right now, the algorithms are labeled as 1.1, 1.2, 2.1, 2.2. However, algorithm 1.1 is shared between both sections. Thus, I want to have them labeled as 1.a and 2.a, 1.b, 2.b, 2.c.

In addition, when I reference those algorithms via ref, the correct numbering will show up (e.g., 1.a, 2.a, etc).

How can I do this?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP