我想使用包以与和相同的方式排版\listofalgorithms
由包生成的。但是,我还没有找到解决该问题的方法。algorithm
\listoffigures
\listoftables
titletoc
以下是 MWE:
\documentclass[12pt,a4paper]{book}
\usepackage{titletoc}
\usepackage[chapter]{algorithm}
\usepackage{algpseudocode}
\renewcommand{\cleardoublepage}{\clearpage}
\titlecontents{figure}[2.0em]{}{\contentslabel{2.3em}}{}{\titlerule*[0.25pc]{.}\contentspage}{}
\titlecontents{table}[2.0em]{}{\contentslabel{2.3em}}{}{\titlerule*[0.25pc]{.}\contentspage}{}
\contentsuse{algorithm}{loa}
\titlecontents{algorithm}[2.0em]{}{\contentslabel{2.3em}}{}{\titlerule*[0.25pc]{.}\contentspage}{}
\begin{document}
\listoffigures
\listoftables
\listofalgorithms
\chapter{Nice chapter}
\begin{figure}[t]
\caption{Nice figure}
\end{figure}
\begin{table}[t]
\caption{Nice table}
\end{table}
\begin{algorithm}[t]
\caption{Nice algorithm}
\end{algorithm}
\end{document}
有人能想到办法吗?
答案1
该\listofalgorithms
命令由包定义。可以通过复制并修补其float
定义来实现:\listoftables
\documentclass[12pt,a4paper]{book}
\usepackage{titletoc}
\usepackage[chapter]{algorithm}
\usepackage{algpseudocode}
\usepackage{etoolbox}
\titlecontents{figure}[2.0em]{}{\contentslabel{2.3em}}{}{\titlerule*[0.25pc]{.}\contentspage}{}
\titlecontents{table}[2.0em]{}{\contentslabel{2.3em}}{}{\titlerule*[0.25pc]{.}\contentspage}{}
\contentsuse{algorithm}{loa}
\titlecontents{algorithm}[2.0em]{}{\contentslabel{2.3em}}{}{\titlerule*[0.25pc]{.}\contentspage}{}
\let\listofalgorithms\listoftables
\patchcmd{\listofalgorithms}{\listtablename}{\listalgorithmname}{}{}
\patchcmd{\listofalgorithms}{\listtablename}{\listalgorithmname}{}{}
\patchcmd{\listofalgorithms}{\listtablename}{\listalgorithmname}{}{}
\patchcmd{\listofalgorithms}{lot}{loa}{}{}
\begin{document}
...
\end{document}