2

I'm referring to this answer of the question on 'how to exclude functions from \listofalgorithms in algorithm2e'. The solution provided in the answer just omits the word function within the list of algorithms, but still prints the function name without a number (the number is replaced by a -).

I would like to completely remove the entries for all functions and procedures from the list of algorithms. Is this possible?

1 Answer 1

3

The minimal example below uses code from the answer to algorithm2e: Exclude functions from \listofalgorithms with the addition of \renewcommand{\addcontentsline}[3]{} in the appropriate location where contents is written to the List of Algorithms:

enter image description here

\documentclass{scrreprt} 

\usepackage{algorithm} 
\usepackage[ruled,algosection,algo2e]{algorithm2e} 

\makeatletter
\long\def\algocf@caption@proc#1[#2]#3{%
  \ifthenelse{\boolean{algocf@nokwfunc}}{\relax}{%
    \SetKwFunction{\algocf@captname#3@}{\algocf@captname#3@}%
  }%
  % we tell hyperref to use algocfproc as category and to take the appropriate ref.
  \ifthenelse{\boolean{algocf@func}}{\def\@proc@func{algocffunc}}{\def\@proc@func{algocfproc}}%
  \@ifundefined{hyper@refstepcounter}{\relax}{% if hyper@refstepcounter undefind, no hyperref, else...
    \ifthenelse{\boolean{algocf@procnumbered}}{% 
      \expandafter\def\csname theH\@proc@func\endcsname{\algocf@captname#3@}%if procnumbered, take \thealgocf as ref
    }{%
      \expandafter\def\csname theH\@proc@func\endcsname{\algocf@captname#3@}%else take procedure or function name
    }%
    \hyper@refstepcounter{\@proc@func}%
  }%
  \ifthenelse{\boolean{algocf@procnumbered}}{\relax}{%
    \addtocounter{algocf}{-1}% \caption do a refstepcounter, so we restore the precedent value
    \gdef\@currentlabel{\algocf@captname#3@}% let the label be the name of the function, not the counter
  }%
  \renewcommand{\addcontentsline}[3]{}% Remove placement of content
  \ifthenelse{\equal{\algocf@captparam#2@}{\arg@e}}{% if no paramater, we remove the ()
    \algocf@latexcaption{#1}[\algocf@captname#2@]{#3}%
  }{%                                                 else we give the complete name
    \algocf@latexcaption{#1}[#2]{#3}%
  }%
}%
\makeatother

\begin{document} 

\begin{function} 
\caption{func()} 
... 
\end{function} 

\begin{algorithm} 
\caption{Foo bar} 
 ... 
\end{algorithm} 

\newpage 
\renewcommand*{\listalgorithmname}{Algorithmenverzeichnis} 
\listofalgorithms 
\clearpage 

\end{document} 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .