I have written a document where I use pseudo code to describe some general algorithms (with \usepackage{algpseudocode}
) which can be viewed at the begining after toc as „List of Algorithms”.
I also use some java code written using \usepackage{listings}
to describe more code. I would like to also add these algorithms written in java to the List Of Algorithms among those written in pseudo code.
Is it possible?
Listings configuration:
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{listings}
\usepackage{courier}
\usepackage{subcaption}
\lstset{
language=Java,
basicstyle=\footnotesize\ttfamily, % Standardschrift
%numbers=left, % Ort der Zeilennummern
numberstyle=\tiny, % Stil der Zeilennummern
%stepnumber=2, % Abstand zwischen den Zeilennummern
numbersep=6pt, % Abstand der Nummern zum Text
tabsize=4, % Groesse von Tabs
extendedchars=true, %
breaklines=true, % Zeilen werden Umgebrochen
keywordstyle=\color{blue},
commentstyle=\itshape\color{gray},
stringstyle=\ttfamily, % Farbe der String
showspaces=false, % Leerzeichen anzeigen ?
showtabs=false, % Tabs anzeigen ?
xleftmargin=17pt,
framexleftmargin=17pt,
framexrightmargin=5pt,
framexbottommargin=4pt,
%backgroundcolor=\color{lightgray},
showstringspaces=false,
morekeywords={get,set,interface, null, var, in}
}
\DeclareCaptionFont{white}{\color{black}}
\DeclareCaptionFormat{listing}{\colorbox[cmyk]{0.13,0.14,0.10,0.1}{\parbox{\textwidth}{\hspace{15pt}#1#2#3}}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white, singlelinecheck=false, margin=0pt, font={bf,footnotesize}}
Best Answer
Here's one possibility;
etoolbox
was used to patch the internal\lst@MakeCaption
(fromlistings
) so the caption is written in the.loa
file (used for\listofalgorithms
):Now that the original question has been edited, the code from my previous example has to be placed before loading
subcaption
: