我一直在准备.cls
修改的文件article.cls
。我需要自定义文档的图表页面列表。
我的文件的图形部分列表.cls
如下:
\newcommand\listoffigures{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\listfigurename}%
\thispagestyle{plain}
\begin{flushright}
{\bf\pagename}
\end{flushright}
\@mkboth{\MakeUppercase\listfigurename}%
{\MakeUppercase\listfigurename}%
\@starttoc{lof}%
\if@restonecol\twocolumn\fi
}
\newcommand*\l@figure{\@dottedtocline{1}{-4.9em}{4.9em}}
当我使用
\listoffigures
打印图表页列表的代码,其生成方式如下:
1.1 Caption of Figure 1.1 .................. 12
1.2 Caption of Figure 1.2 .................. 17
2.1 Caption of Figure 2.1 .................. 25
2.2 Caption of Figure 2.2 .................. 26
但所需的图页列表必须如下:
Figure 1.1 Caption of Figure 1.1 .................. 12
Figure 1.2 Caption of Figure 1.2 .................. 17
Figure 2.1 Caption of Figure 2.1 .................. 25
Figure 2.2 Caption of Figure 2.2 .................. 26
为此,我该如何修改.cls
文件?
答案1
这不是对 的重新定义,而是通过定义一个带有前缀(如 所包含)的列表格式\listoffigures
来使用非常复杂的包提供的功能,如果没有使用,则必须在类文件中将其稍微重新定义更改为。caption
figurenew
Figure
\figurename
\l@figure
\newcommand{\l@figure}
\LoadClass{article}
\documentclass[12pt]{article}
\usepackage[demo]{graphicx}%
\usepackage{caption}
\makeatletter
\renewcommand*\l@figure{\@dottedtocline{1}{0em}{7em}}
\makeatother
\DeclareCaptionListFormat{figurenew}{\textbf{\figurename}~#1 #2}%
\captionsetup{listformat=figurenew}
\renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}
\begin{document}
\listoffigures
\clearpage
\section{first}
\begin{figure}
\includegraphics[width=5cm,height=3cm]{somefig}%
\caption{Some caption number one}
\end{figure}
\begin{figure}
\includegraphics[width=5cm,height=3cm]{somefig}%
\caption{Some caption number one}
\end{figure}
\setcounter{section}{99}
\section{Hundred}
\begin{figure}
\includegraphics[width=5cm,height=3cm]{somefig}%
\caption{Some caption number three}
\end{figure}
\end{document}
答案2
\listfiles
\documentclass{report}
\def\pagename{Page}
\makeatletter
\renewcommand\listoffigures{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\listfigurename}%
\thispagestyle{plain}
\begin{flushright}
{\bf\pagename}
\end{flushright}
\@mkboth{\MakeUppercase\listfigurename}%
{\MakeUppercase\listfigurename}%
\@starttoc{lof}%
\if@restonecol\twocolumn\fi
}
\renewcommand*\l@figure{\@dottedtocline{1}{-4.9em}{4.9em}}
\long\def\@caption#1[#2]#3{%
\par
\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\protect\numberline{Figure \csname the#1\endcsname}{\ignorespaces #2}}%
\begingroup
\@parboxrestore
\if@minipage
\@setminipage
\fi
\normalsize
\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
\endgroup}
\makeatother
\begin{document}
\chapter{foo}
\begin{figure}
foo\caption{bar}
\end{figure}
\listoffigures
\end{document}