我正在写论文,我的算法列表有一个小小的格式问题。
条目已正确添加到目录中,字体、大小点和数字都完美无缺,但不知何故,LOA 比页面顶部的 LOF/LOT 低了大约一厘米。
这是我的 MWE:
\RequirePackage[l2tabu, orthodox]{nag}
\documentclass[12pt]{report}
\usepackage{setspace}
\usepackage{layout}
\usepackage{fullpage}
\usepackage{caption}
\usepackage[list=true, listformat=simple]{subcaption}
\usepackage{tocloft}
\usepackage{algorithm}
\usepackage[noend]{algorithmic}
\pagestyle{plain}
\begin{document}
\pagenumbering{roman}
\newpage
\singlespacing
\renewcommand{\contentsname}{Table of Contents}
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}
\renewcommand{\cftchapnumwidth}{7em}
\makeatletter
\newcommand*\updatechaptername{%
\addtocontents{toc}{\protect\renewcommand*\protect\cftchappresnum{\@chapapp\ }}
}
\makeatother
\tableofcontents
\updatechaptername
\newpage
\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures
\newpage
\addcontentsline{toc}{chapter}{List of Tables}
\listoftables
\newpage
\addcontentsline{toc}{chapter}{List of Algorithms}
\listofalgorithms
\doublespacing
\newpage
\pagenumbering{arabic}
\chapter{Introduction}
\label{chap:intro}
\newpage
\chapter{Content}
\label{chap:content}
\end{document}
答案1
问题是由于 packagefloat
命令\listof
(由 package 加载algorithms
)的格式与 package 不同tocloft
。下面的命令(未经实际算法测试)应该可以工作。它是命令的复制粘贴\listoffigures
tocloft
,经过适当修改。(另请参阅文档的已知问题部分algorithms
)
[你的 mwe 缺少\begin{document}
,我无法在评论中提及它,因为我没有获得足够的声誉点]
\RequirePackage[l2tabu, orthodox]{nag}
\documentclass[12pt]{report}
\usepackage{setspace}
\usepackage{layout}
\usepackage{fullpage}
\usepackage{caption}
\usepackage[list=true, listformat=simple]{subcaption}
\usepackage{tocloft}
\usepackage{algorithm}
\usepackage[noend]{algorithmic}
\makeatletter
\AtBeginDocument{%
\renewcommand{\listofalgorithms}{%
\@cfttocstart \par \begingroup
\parindent\z@ \parskip\cftparskip
\addpenalty \@secpenalty
\if@cfthaschapter \vspace*{\cftbeforeloftitleskip } \else
\vspace {\cftbeforeloftitleskip } \fi
\@cftpagestyle
{\interlinepenalty \@M
{\cftloftitlefont \listalgorithmname }%
{\cftafterloftitle }
\@mkboth {\MakeUppercase \listalgorithmname }
{\MakeUppercase \listalgorithmname }
\par \nobreak \vskip \cftafterloftitleskip \@afterheading }%
\let\l@algorithm\l@figure
\@starttoc {loa}\endgroup
\@cfttocfinish }}
\makeatother
\pagestyle{plain}
\pagenumbering{roman}
\newpage
\singlespacing
\renewcommand{\contentsname}{Table of Contents}
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}
\renewcommand{\cftchapnumwidth}{7em}
\makeatletter
\newcommand*\updatechaptername{%
\addtocontents{toc}{\protect\renewcommand*\protect\cftchappresnum{\@chapapp\ }}
}
\makeatother
\begin{document}
\tableofcontents
\updatechaptername
\newpage
\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures
\newpage
\addcontentsline{toc}{chapter}{List of Tables}
\listoftables
\newpage
\addcontentsline{toc}{chapter}{List of Algorithms}
\listofalgorithms
\doublespacing
\newpage
\pagenumbering{arabic}
\chapter{Introduction}
\label{chap:intro}
\newpage
\chapter{Content}
\label{chap:content}
\end{document}