我正在使用classicthesis
版本2012/08/12 v4.1
。我希望图号包含章节号(例如 1.1、1.1、...、10.1、10.2、10.3、...),并重置每个章节的图计数器。以下是 MWE。
\documentclass[
%twoside,
openright,
titlepage, numbers=noenddot, headinclude,%1headlines,
footinclude=true, cleardoublepage=empty,
BCOR=30mm, paper=letter, fontsize=11pt, % Binding correction, paper type and font size
dottedtoc,
ngerman, american, % Languages
]{scrreprt}
\PassOptionsToPackage{%
eulerchapternumbers,
listings,
%drafting,
pdfspacing,
%floatperchapter,
%linedheaders,%
subfig,
beramono,
% eulermath, % This changes the font for math equations.
parts}{classicthesis}
\usepackage{tabularx} % Better tables
\setlength{\extrarowheight}{3pt} % Increase table row height
\newcommand{\tableheadline}[1]{\multicolumn{1}{c}{\spacedlowsmallcaps{#1}}}
\newcommand{\myfloatalign}{\centering} % To be used with each float for alignment
\usepackage{caption}
\DeclareCaptionLabelFormat{myformat}{#1~\thechapter.#2}
\captionsetup{format=hang, font=small, labelformat=myformat}
\usepackage[position=t,singlelinecheck=off,font={it}]{subfig}
\usepackage{classicthesis}
\begin{document}
\listoffigures
\chapter{ch01}
\begin{figure}
\centering
\rule{6.4cm}{3.6cm}
\caption{This is the figure in chapter number one.}
\label{fig1}
\end{figure}
\setcounter{figure}{0}
\chapter{ch02}
\begin{figure}
\centering
\rule{6.4cm}{3.6cm}
\caption{This is the figure in chapter number two.}
\label{fig2}
\end{figure}
\end{document}
我能够使用修改图片标题\DeclareCaptionLabelFormat{myformat}{#1~\thechapter.#2}
,并且它在每一章中都能正常工作。但是,当我查看图片列表时,它与每章中的图片编号不兼容,即它没有章节编号。有人能帮我吗?
另外,有没有更简单的方法可以在每章之前将计数器重置为零?我应该在每次每章之前重置计数器吗?我们可以在序言中添加一些内容,当检测到新章节时自动将计数器重置为零吗?
答案1
您所做的更改仅影响标题中的标签。您可以使用以下方法实现所需的功能
\usepackage{chngcntr}
\counterwithin{figure}{chapter}
完整示例:
\documentclass[
%twoside,
openright,
titlepage, numbers=noenddot, headinclude,%1headlines,
footinclude=true, cleardoublepage=empty,
BCOR=30mm, paper=letter, fontsize=11pt, % Binding correction, paper type and font size
dottedtoc,
ngerman, american, % Languages
]{scrreprt}
\usepackage[%
eulerchapternumbers,
listings,
%drafting,
pdfspacing,
%floatperchapter,
%linedheaders,%
subfig,
beramono,
% eulermath, % This changes the font for math equations.
parts]{classicthesis}
\usepackage[position=t,singlelinecheck=off,font={it}]{subfig}
\usepackage{tabularx} % Better tables
\usepackage{chngcntr}
\usepackage{caption}
\counterwithin{figure}{chapter}
\setlength{\extrarowheight}{3pt} % Increase table row height
\newcommand{\tableheadline}[1]{\multicolumn{1}{c}{\spacedlowsmallcaps{#1}}}
\newcommand{\myfloatalign}{\centering} % To be used with each float for alignment
\captionsetup{format=hang, font=small}
\begin{document}
\listoffigures
\chapter{ch01}
\begin{figure}
\centering
\rule{6.4cm}{3.6cm}
\caption{This is the figure in chapter number one.}
\label{fig1}
\end{figure}
\setcounter{figure}{0}
\chapter{ch02}
\begin{figure}
\centering
\rule{6.4cm}{3.6cm}
\caption{This is the figure in chapter number two.}
\label{fig2}
\end{figure}
\end{document}
生成的 LoF 的图像:
无需额外的软件包,你可以使用以下方法实现相同的效果
\makeatletter
\renewcommand\thefigure{\arabic{chapter}.\arabic{figure}}
\@addtoreset{figure}{chapter}
\makeatother