我正在使用自定义模板,似乎无法正确添加算法列表。当我简单地尝试时\listofalgorithms
,结果如下:
代替算法,数字显示在列表中。
其他条目(如表格、图表和列表)的预定义格式如下:
%*******************************************************
% List of Figures
%*******************************************************
%\phantomsection
%\addcontentsline{toc}{chapter}{\listfigurename}
\pdfbookmark[0]{\listfigurename}{lof}
\listoffigures
\vspace{8ex}
%*******************************************************
% List of Tables
%*******************************************************
%\phantomsection
%\addcontentsline{toc}{chapter}{\listtablename}
\pdfbookmark[0]{\listtablename}{lot}
\listoftables
\vspace{8ex}
% \newpage
%*******************************************************
% List of Listings
%*******************************************************
%\phantomsection
%\addcontentsline{toc}{chapter}{\lstlistlistingname}
\pdfbookmark[0]{\lstlistlistingname}{lol}
\lstlistoflistings
\vspace{8ex}
并且配置如下:
% ********************************************************************
% layout of the TOC, LOF and LOT (LOL-workaround see next section)
% ********************************************************************
\PassOptionsToPackage{titles}{tocloft}
\RequirePackage{tocloft}
% avoid page numbers being right-aligned in fixed-size box
\newlength{\newnumberwidth}
\settowidth{\newnumberwidth}{999} % yields overfull hbox warnings for pages > 999
\cftsetpnumwidth{\newnumberwidth}
% have the bib neatly positioned after the rest
\newlength{\beforebibskip}
\setlength{\beforebibskip}{0em}
% space for more than nine chapters
\newlength{\newchnumberwidth}
\settowidth{\newchnumberwidth}{.} % <--- tweak here if more space required
\ifthenelse{\boolean{ct@manychapters}}% <--- many chapters option
{%
\addtolength{\cftchapnumwidth}{\newchnumberwidth}%
\addtolength{\cftsecnumwidth}{\newchnumberwidth}
\addtolength{\cftsecindent}{\newchnumberwidth}
\addtolength{\cftsubsecnumwidth}{\newchnumberwidth}
\addtolength{\cftsubsecindent}{2\newchnumberwidth}
\addtolength{\cftsubsubsecnumwidth}{\newchnumberwidth}
}{\relax}%
% pagenumbers right after the titles
% parts
\ifthenelse{\boolean{ct@parts}}%
{%
\renewcommand{\thepart}{\roman{part}}%
\renewcommand{\cftpartpresnum}{\scshape}% \MakeTextLowercase
\renewcommand{\cftpartaftersnum}{}%
\renewcommand{\cftpartaftersnumb}{\spacedlowsmallcaps}%
\setlength{\cftpartnumwidth}{\cftchapnumwidth}
\renewcommand{\cftpartfont}{\color{CTtitle}\normalfont}%
\cftpagenumbersoff{part}
\renewcommand{\cftpartpagefont}{\normalfont}%
\ifthenelse{\boolean{ct@dottedtoc}}{\relax}%
{%
\renewcommand{\cftpartleader}{\hspace{1.5em}}%
\renewcommand{\cftpartafterpnum}{\cftparfillskip}%
}%
\setlength{\cftbeforepartskip}{1em}%
\setlength{\cftbeforechapskip}{.1em}%
\setlength{\beforebibskip}{1.5\cftbeforepartskip}%
}{\relax}
% chapters
\ifthenelse{\boolean{ct@nochapters}}%
{\relax}%
{%
\renewcommand{\cftchappresnum}{\spacedlowsmallcaps}%
\renewcommand{\cftchapaftersnumb}{\spacedlowsmallcaps}%
\renewcommand{\cftchapfont}{\normalfont}%
\renewcommand{\cftchappagefont}{\normalfont}%
\ifthenelse{\boolean{ct@dottedtoc}}{\relax}%
{%
\renewcommand{\cftchapleader}{\hspace{1.5em}}%
\renewcommand{\cftchapafterpnum}{\cftparfillskip}%
}
%\setlength{\cftbeforechapskip}{.1em}%
}
% sections
\ifthenelse{\boolean{ct@nochapters}}%
{%
\setlength{\cftbeforesecskip}{.1em}%
\setlength{\beforebibskip}{1em}%
}%
{\relax}
\renewcommand{\cftsecpresnum}{\scshape\MakeTextLowercase}%
\renewcommand{\cftsecfont}{\normalfont}%
\renewcommand{\cftsecpagefont}{\normalfont}%
\ifthenelse{\boolean{ct@dottedtoc}}{\relax}%
{%
\renewcommand{\cftsecleader}{\hspace{1.5em}}%
\renewcommand{\cftsecafterpnum}{\cftparfillskip}%
}
\ifthenelse{\boolean{ct@tocaligned}}{\renewcommand{\cftsecindent}{0em}}{\relax}
% subsections
\renewcommand{\cftsubsecpresnum}{\scshape\MakeTextLowercase}%
\renewcommand{\cftsubsecfont}{\normalfont}%
\ifthenelse{\boolean{ct@dottedtoc}}{\relax}%
{%
\renewcommand{\cftsubsecleader}{\hspace{1.5em}}%
\renewcommand{\cftsubsecafterpnum}{\cftparfillskip}%
}
\ifthenelse{\boolean{ct@tocaligned}}{\renewcommand{\cftsubsecindent}{0em}}{\relax}
% subsubsections
\renewcommand{\cftsubsubsecpresnum}{\scshape\MakeTextLowercase}%
\renewcommand{\cftsubsubsecfont}{\normalfont}%
\ifthenelse{\boolean{ct@dottedtoc}}{\relax}%
{%
\renewcommand{\cftsubsubsecleader}{\hspace{1.5em}}%
\renewcommand{\cftsubsubsecafterpnum}{\cftparfillskip}%
}
\ifthenelse{\boolean{ct@tocaligned}}{\renewcommand{\cftsubsubsecindent}{0em}}{\relax}
% figures
\renewcommand{\cftfigpresnum}{\scshape\MakeTextLowercase}%
\renewcommand{\cftfigfont}{\normalfont}%
\ifthenelse{\boolean{ct@dottedtoc}}{\relax}%
{%
\renewcommand{\cftfigleader}{\hspace{1.5em}}%
\renewcommand{\cftfigafterpnum}{\cftparfillskip}%
}
\renewcommand{\cftfigpresnum}{\figurename~}%Fig.~}
\newlength{\figurelabelwidth}
\settowidth{\figurelabelwidth}{\cftfigpresnum~999}
\addtolength{\figurelabelwidth}{2.5em}
\cftsetindents{figure}{0em}{\figurelabelwidth}
% tables
\renewcommand{\cfttabpresnum}{\scshape\MakeTextLowercase}%
\renewcommand{\cfttabfont}{\normalfont}%
\ifthenelse{\boolean{ct@dottedtoc}}{\relax}%
{%
\renewcommand{\cfttableader}{\hspace{1.5em}}%
\renewcommand{\cfttabafterpnum}{\cftparfillskip}%
}
\renewcommand{\cfttabpresnum}{\tablename~}%Tab.~}
\newlength{\tablelabelwidth}
\settowidth{\tablelabelwidth}{\cfttabpresnum~999}
\addtolength{\tablelabelwidth}{2.5em}
%\cftsetindents{table}{0em}{\tablelabelwidth}
\cftsetindents{table}{0em}{\figurelabelwidth}
% listings
\ifthenelse{\boolean{ct@listings}}%
{%
\newlistof{listings}{lol}{\lstlistlistingname}%
\renewcommand{\cftlistingspresnum}{\scshape\MakeTextLowercase}%
\renewcommand{\cftlistingsfont}{\normalfont}%
\renewcommand{\cftlistingspresnum}{\lstlistingname~}%
\renewcommand{\cftlistingspagefont}{\normalfont}%
\ifthenelse{\boolean{ct@dottedtoc}}{\relax}%
{%
\renewcommand{\cftlistingsleader}{\hspace{1.5em}}%
\renewcommand{\cftlistingsafterpnum}{\cftparfillskip}%
}
\newlength{\listingslabelwidth}%
\settowidth{\listingslabelwidth}{\cftlistingspresnum~999}%
\addtolength{\listingslabelwidth}{2.5em}%
%\cftsetindents{listings}{0em}{\listingslabelwidth}%
\cftsetindents{listings}{0em}{\figurelabelwidth}%
\let\l@lstlisting\l@listings%
\let\lstlistoflistings\listoflistings%
}{\relax}%
% dirty work-around to get the spacing after the toc/lot/lof-titles right
\ifthenelse{\boolean{ct@parts}}%
{%
\AtBeginDocument{\addtocontents{toc}{\protect\vspace{-\cftbeforepartskip}}}
}{%
\ifthenelse{\boolean{ct@nochapters}}%
{\relax}%
{\AtBeginDocument{\addtocontents{toc}{\protect\vspace{-\cftbeforechapskip}}}}
}
我使用\usepackage{algorithm}
和\usepackage{algpseudocode}
作为我的算法。
答案1
我找到解决办法了!
在 classicthesis.sty 中:
在第 63 行之后,我添加了:
\DeclareBoolOption{algorithm} % OBSOLETE - automatic check; load algorithm package and setup LoA
在第 110 行之后,我添加了:
\@ifpackageloaded{algorithm} {\setboolean{ct@algorithm}{true}% }{\relax} \ifthenelse{\boolean{ct@algorithm}}% {\RequirePackage{algorithm}% }{\relax}
在第 565 行之后,我添加了:
\ifthenelse{\boolean{ct@algorithm}} %Check if Algorithm is loaded { \renewcommand{\cftfigpresnum}{Algorithm~}%Fig.~} }{\relax}
在文件 classicthesis-config.tex 中:
您必须algorithm
在 sty 文件之前调用。因此,在第 180 行左右,我的文件如下所示:
...
% ****************************************************************************************************
% 5. Setup code listings
% ****************************************************************************************************
\usepackage{listings}
%\lstset{emph={trueIndex,root},emphstyle=\color{BlueViolet}}%\underbar} % for special keywords
\lstset{language=[LaTeX]Tex,%C++,
morekeywords={PassOptionsToPackage,selectlanguage},
keywordstyle=\color{RoyalBlue},%\bfseries,
basicstyle=\small\ttfamily,
%identifierstyle=\color{NavyBlue},
commentstyle=\color{Green}\ttfamily,
stringstyle=\rmfamily,
numbers=none,%left,%
numberstyle=\scriptsize,%\tiny
stepnumber=5,
numbersep=8pt,
showstringspaces=false,
breaklines=true,
%frameround=ftff,
%frame=single,
belowcaptionskip=.75\baselineskip
%frame=L
}
% ****************************************************************************************************
\usepackage{algorithm}
\usepackage{algpseudocode}
% ****************************************************************************************************
% 6. Last calls before the bar closes
% ****************************************************************************************************
% ********************************************************************
% Her Majesty herself
% ********************************************************************
\usepackage{classicthesis}
...
最后,在文件 Contents.tex 中:
...
%*******************************************************
% List of Listings
%*******************************************************
\phantomsection
%\addcontentsline{toc}{chapter}{\lstlistlistingname}
\newpage
\pdfbookmark[1]{\lstlistlistingname}{loa}
% \lstlistoflistings
\listofalgorithms
\vspace{8ex}
...