![减少算法标题列表的大小](https://linux22.com/image/346417/%E5%87%8F%E5%B0%91%E7%AE%97%E6%B3%95%E6%A0%87%E9%A2%98%E5%88%97%E8%A1%A8%E7%9A%84%E5%A4%A7%E5%B0%8F.png)
我曾经使用过的报告类文档,文档中用到的所有包如下:
\documentclass[12pt,a4paper]{report}
%%%%%%%%%%%%%% packages %%%%%%%%%%%%%
\usepackage{amsthm,amssymb,amsmath,enumerate}
\usepackage{mathrsfs}
\usepackage[cam,a4,center,noinfo]{crop}
\usepackage[top=45mm, bottom=45mm, left=40mm, right=40mm]{geometry}
\usepackage{tikz}
\usepackage{tocloft}
\usepackage{emptypage}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{framed}
\usepackage[textfont={footnotesize},labelfont={bf,small},format=hang,labelsep=quad]{caption}
\usepackage{subcaption}
\usepackage[nottoc,notlof,notlot]{tocbibind}
\usepackage{makeidx}
\makeindex
\usepackage{cite}
\usepackage{titlesec}
\usepackage{indentfirst}
\usepackage{color}
\definecolor{Blue}{rgb}{0,0,.55}
\usepackage[colorlinks=true,linkcolor=Blue,urlcolor=Blue,citecolor=Blue]{hyperref}
\begin{document}
\tableofcontents
\listofalgorithms
\chapter{Chapter First}
\begin{algorithm}
\caption{The generalized global Arnoldi algorithm}
\label{alg1}
\begin{algorithmic}[1]
\STATE Set $\beta=\Arrowvert V\Arrowvert_{F}$, $V_{1}=V/\beta.$
\FOR {$j=1, \ldots, k$}
\STATE $W_{j}=AV_{j}B$
\FOR{$i=1, \ldots, j$}
\STATE $W_{j}=W_{j}-h_{ij}V_{i}$
\ENDFOR
\STATE $h_{j+1, j}=\Arrowvert W_{j}\Arrowvert_{F}.$ If $h_{j+1, j}=0$ then stop.
\STATE $V_{j+1}=W_{j}/h_{j+1, j}.$
\ENDFOR
\end{algorithmic}
\end{algorithm}
\end{document}
为了创建算法列表,我应用以下命令
\listofalgorithms
有没有办法可以减少算法标题列表的大小?
答案1
我建议重新定义负责排版标题的命令。将以下命令放入你的序言中。
\makeatletter
\renewcommand\float@listhead[1]%
{\@ifundefined{chapter}%
{\def\@tempa{\section*}}%
{\def\@tempa{\chapter*}}%
\@tempa
{\listheaderformat#1\@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}%
}
\newcommand\listheaderformat{}
\makeatother
要全局更改所有列表的标题格式,请添加以下行
\renewcommand\listheaderformat{\small}
回到序言,紧接着上述定义。
要仅更改一个列表的标题格式,请将此行直接添加到相应列表之前并将其括在一个组中。
{\renewcommand\listheaderformat{\small}%
\listofalgorithms
}
这是原始帖子的代码以及建议的重新定义。
\documentclass[12pt,a4paper]{report}
%%%%%%%%%%%%%% packages %%%%%%%%%%%%%
\usepackage{amsthm,amssymb,amsmath,enumerate}
\usepackage{mathrsfs}
\usepackage[cam,a4,center,noinfo]{crop}
\usepackage[top=45mm, bottom=45mm, left=40mm, right=40mm]{geometry}
\usepackage{tikz}
\usepackage{tocloft}
\usepackage{emptypage}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{framed}
\usepackage[textfont={footnotesize},labelfont={bf,small},format=hang,labelsep=quad]{caption}
\usepackage{subcaption}
\usepackage[nottoc,notlof,notlot]{tocbibind}
\usepackage{makeidx}
\makeindex
\usepackage{cite}
\usepackage{titlesec}
\usepackage{indentfirst}
\usepackage{color}
\definecolor{Blue}{rgb}{0,0,.55}
\usepackage[colorlinks=true,linkcolor=Blue,urlcolor=Blue,citecolor=Blue]{hyperref}
\makeatletter
\renewcommand\float@listhead[1]%
{\@ifundefined{chapter}%
{\def\@tempa{\section*}}%
{\def\@tempa{\chapter*}}%
\@tempa
{\listheaderformat#1\@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}%
}
\newcommand\listheaderformat{}
\makeatother
\renewcommand\listheaderformat{\small}
\begin{document}
\tableofcontents
\listofalgorithms
\chapter{Chapter First}
\begin{algorithm}
\caption{The generalized global Arnoldi algorithm}
\label{alg1}
\begin{algorithmic}[1]
\STATE Set $\beta=\Arrowvert V\Arrowvert_{F}$, $V_{1}=V/\beta.$
\FOR {$j=1, \ldots, k$}
\STATE $W_{j}=AV_{j}B$
\FOR{$i=1, \ldots, j$}
\STATE $W_{j}=W_{j}-h_{ij}V_{i}$
\ENDFOR
\STATE $h_{j+1, j}=\Arrowvert W_{j}\Arrowvert_{F}.$ If $h_{j+1, j}=0$ then stop.
\STATE $V_{j+1}=W_{j}/h_{j+1, j}.$
\ENDFOR
\end{algorithmic}
\end{algorithm}
\end{document}
答案2
快速破解:\renewcommand{\listalgorithmname}{\small List of Algorithms}
或您想要的任何尺寸。
梅威瑟:
\documentclass[12pt,a4paper]{report}
%%%%%%%%%%%%%% packages %%%%%%%%%%%%%
\usepackage{amsthm,amssymb,amsmath,enumerate}
\usepackage{mathrsfs}
\usepackage[cam,a4,center,noinfo]{crop}
\usepackage[top=45mm, bottom=45mm, left=40mm, right=40mm]{geometry}
\usepackage{tikz}
\usepackage{tocloft}
\usepackage{emptypage}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{framed}
\usepackage[textfont={footnotesize},labelfont={bf,small},format=hang,labelsep=quad]{caption}
\usepackage{subcaption}
\usepackage[nottoc,notlof,notlot]{tocbibind}
\usepackage{makeidx}
\makeindex
\usepackage{cite}
\usepackage{titlesec}
\usepackage{indentfirst}
\usepackage{color}
\definecolor{Blue}{rgb}{0,0,.55}
\usepackage[colorlinks=true,linkcolor=Blue,urlcolor=Blue,citecolor=Blue]{hyperref}
\renewcommand{\listalgorithmname}{\small List of Algorithms}
\begin{document}
\tableofcontents
\listofalgorithms
\chapter{Chapter First}
\begin{algorithm}
\caption{The generalized global Arnoldi algorithm}
\label{alg1}
\begin{algorithmic}[1]
\STATE Set $\beta=\Arrowvert V\Arrowvert_{F}$, $V_{1}=V/\beta.$
\FOR {$j=1, \ldots, k$}
\STATE $W_{j}=AV_{j}B$
\FOR{$i=1, \ldots, j$}
\STATE $W_{j}=W_{j}-h_{ij}V_{i}$
\ENDFOR
\STATE $h_{j+1, j}=\Arrowvert W_{j}\Arrowvert_{F}.$ If $h_{j+1, j}=0$ then stop.
\STATE $V_{j+1}=W_{j}/h_{j+1, j}.$
\ENDFOR
\end{algorithmic}
\end{algorithm}
\end{document}
笔记:如果算法列表的名称也在其他任何地方使用,例如目录或页眉,这也会改变那里的字体大小 - 所以在这种情况下您肯定希望使用更复杂的解决方案。