我正在使用该algorithm
软件包为 Claudio Beccari 撰写的论文创建算法列表toptesi
。但是,我无法将算法列表包含在目录中。目前,我正在使用命令生成列表和目录。\figurespagetrue \tablespagetrue \indici
有没有办法将算法列表包含在目录中,或者是否有命令可用于实现此目的?
答案1
添加了 的重新定义,以便在之前调用\indici
时生成并包含算法列表(带有标题)。\algospagetrue
\indici
算法的编号方式与表格和图形相同(添加章节编号)。
用于\renewcommand{\listalgorithmname}{<title>}
改变算法列表的名称。
。
% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = pdflatex
\documentclass[%
corpo=13pt,
twoside,
% stile=classica,
oldstyle,
autoretitolo,
greek,
evenboxes,
% tipotesi,
]{toptesi}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[utf8]{inputenc}% si può scegliere anche latin1, ma lo si sconsiglia fortemente
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{lipsum}
%%*********************************************** added <<<<<<<<<<<<<<<<
\usepackage{algpseudocode} % added here <<<<<<<<<<<<<<<<
\usepackage{algorithm} % added here <<<<<<<<<<<<<<<<
\newif\ifalgospage
\algospagefalse
\renewcommand{\listalgorithmname}{Elenco degli algoritmi}% to change the list name <<<<<<<<<<<
\renewcommand{\indici}{%
\iffrontmatter\else\frontmattertrue\fi
\tableofcontents
\iftablespage
{\addvspace{10pt}
\let\saveaddvspace=\addvspace%
\def\addvspace##1{}
\listoftables
\let\addvspace=\saveaddvspace}
\fi
\iffigurespage
{\addvspace{10pt}
\let\saveaddvspace=\addvspace%
\def\addvspace##1{}
\listoffigures
\let\addvspace=\saveaddvspace}
\fi
\ifalgospage % added <<<<<<<<<<
{\addvspace{10pt}
\let\saveaddvspace=\addvspace%
\def\addvspace##1{}
\addcontentsline{toc}{chapter}{\listalgorithmname}
\listofalgorithms
\let\addvspace=\saveaddvspace}
\fi
\ifbool{@twoside}{\cleardoublepage[empty]}{}}
\let\allcontents\indici
\onecolumn
\if@twoside
\unless\ifScuDo
\flushbottom
\else
\raggedbottom
\fi
\else
\ifx\@xivpt\f@size
\raggedbottom
\else
\flushbottom
\fi
\fi
\brokenpenalty=10000
\def\interlinea#1{\linespread{#1}\selectfont}
\def\endinterlinea{\par}
\def\@floatboxreset{%
\reset@font
\linespread{1}%
\normalsize
\@setminipage
}
\makeatletter
\renewcommand\thealgorithm{\thechapter.\arabic{algorithm}} % add the chapter number to the algorithm number <<<<
\@addtoreset{algorithm}{chapter}
\makeatother
%%**********************************************
\usepackage{hyperref} % must be last package <<<<<<<<<<<<
\hypersetup{%
pdfpagemode={UseOutlines},
bookmarksopen,
pdfstartview={FitH},
colorlinks,
linkcolor={blue},
citecolor={blue},
urlcolor={blue}
}
\begin{document}
\tablespagetrue
\figurespagetrue
\algospagetrue % to produce and include the list of algorithms to the indice <<<<<<<<<<<<<<<<<<<<<<<<
\indici
\mainmatter
\part{Prima Parte}
\chapter{Introduzione generale}
\lipsum[1]
Le grandezze in gioco sono evidenziate nella figura \ref{fig:orbita}.
\begin{figure}[ht!]
\caption{Orbita del generico satellite; si noti l'eccentricit\`a dell'orbita rispetto al pianeta.}\label{fig:orbita}
\end{figure}
\chapter{Il barometro}
Il mercurio gode della sorprendente qualit\`a et propriet\`a, cio\`e che esso
diventa tanto solido da potersene fare una testa di martello et infiggere
chiodi aguzzi nel legname.
\begin{table}[htp!] % crea un floating body col nome Tabella nella
\centering % comando necessario per centrare la tabella
\caption[Densit\`a del mercurio]{Densit\`a del mercurio} \label{t:1} % didascalia con label
\end{table}
\chapter{Diversi algoritmi}
\begin{algorithm}[ht!]
\caption{An algorithm with caption}\label{alg:cap}
\begin{algorithmic}
\Require $n \geq 0$
\Ensure $y = x^n$
\State $y \gets 1$
\State $X \gets x$
\State $N \gets n$
\While{$N \neq 0$}
\If{$N$ is even}
\State $X \gets X \times X$
\State $N \gets \frac{N}{2} $ \Comment{This is a comment}
\ElsIf{$N$ is odd}
\State $y \gets y \times X$
\State $N \gets N - 1$
\EndIf
\EndWhile
\end{algorithmic}
\end{algorithm}
\end{document}