我试图让章节出现在标题中,但它总是只显示“内容”。以下是我的演示代码:
\documentclass{report}
\usepackage[demo]{graphicx}
\usepackage[final]{pdfpages}
\usepackage{hyperref}
\usepackage{fancyhdr}
\usepackage[letterpaper, margin=1in]{geometry}
\usepackage{subcaption}
\usepackage{tocloft}
\pagestyle{fancy}
\lfoot{\today}
\rfoot{\thepage}
\cfoot{}
\rhead{}
\lhead{\leftmark}
\renewcommand {\headrulewidth}{0.4pt}
\renewcommand {\footrulewidth}{0.4pt}
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}
\begin{document}\thispagestyle{empty}
\setlength\unitlength{1in}
\clearpage\phantomsection
\tableofcontents
\clearpage\phantomsection
\addcontentsline{toc}{chapter}{Chapter 1}
\begin{figure}[ht]
\captionsetup[subfigure]{labelformat=empty}
\centering
\begin{subfigure}{2.125in}
\centering
\framebox(2,2){\includegraphics[width=1.875in,height=1.875in,keepaspectratio]{infinity_80_gf_2010}}
\caption{A subfigure}
\label{fig:sub1}
\end{subfigure}%
\begin{subfigure}{2.125in}
\centering
\framebox(2,2){\includegraphics[width=1.875in,height=1.875in,keepaspectratio]{Plus80_2010}}
\caption{A subfigure}
\label{fig:sub1}
\end{subfigure}%
\begin{subfigure}{2.125in}
\centering
\framebox(2,2){\includegraphics[width=1.875in,height=1.875in,keepaspectratio]{comfort_achp_Puron}}
\caption{A subfigure}
\label{fig:sub1}
\end{subfigure}
\end{figure}
\begin{figure}[Hb]
\captionsetup[subfigure]{labelformat=empty}
\centering
\begin{subfigure}{2.125in}
\centering
\framebox(2,2){\includegraphics[width=1.875in,height=1.875in,keepaspectratio]{infinity_80_gf_2010}}
\caption{A subfigure}
\label{fig:sub1}
\end{subfigure}%
\begin{subfigure}{2.125in}
\centering
\framebox(2,2){\includegraphics[width=1.875in,height=1.875in,keepaspectratio]{Plus80_2010}}
\caption{A subfigure}
\label{fig:sub1}
\end{subfigure}%
\begin{subfigure}{2.125in}
\centering
\framebox(2,2){\includegraphics[width=1.875in,height=1.875in,keepaspectratio]{comfort_achp_Puron}}
\caption{A subfigure}
\label{fig:sub1}
\end{subfigure}
\end{figure}
\end{document}
这是输出:
我希望它显示“第 1 章”
答案1
\documentclass{report}
\usepackage[demo]{graphicx}
\usepackage[final]{pdfpages}
\usepackage{fancyhdr}
\usepackage[letterpaper, margin=1in]{geometry}
\usepackage{subcaption}
\usepackage{tocloft}
\usepackage{blindtext}
\usepackage{hyperref}
\pagestyle{fancy}
\lfoot{\today}
\rfoot{\thepage}
\cfoot{}%
\rhead{}%
\lhead{\leftmark}
\renewcommand {\headrulewidth}{0.4pt}
\renewcommand {\footrulewidth}{0.4pt}
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}
\begin{document}\thispagestyle{empty}
\setlength\unitlength{1in}
\clearpage\phantomsection
\tableofcontents
\clearpage\phantomsection
\chapter{My first chapter}%
%\addcontentsline{toc}{chapter}{Chapter 1}
\begin{figure}[ht]
\captionsetup[subfigure]{labelformat=empty}
\centering
\begin{subfigure}{2.125in}
\centering
\framebox(2,2){\includegraphics[width=1.875in,height=1.875in,keepaspectratio]{infinity_80_gf_2010}}
\caption{A subfigure}
\label{fig:sub1}
\end{subfigure}%
\begin{subfigure}{2.125in}
\centering
\framebox(2,2){\includegraphics[width=1.875in,height=1.875in,keepaspectratio]{Plus80_2010}}
\caption{A subfigure}
\label{fig:sub1}
\end{subfigure}%
\begin{subfigure}{2.125in}
\centering
\framebox(2,2){\includegraphics[width=1.875in,height=1.875in,keepaspectratio]{comfort_achp_Puron}}
\caption{A subfigure}
\label{fig:sub1}
\end{subfigure}
\end{figure}
\begin{figure}[Hb]
\captionsetup[subfigure]{labelformat=empty}
\centering
\begin{subfigure}{2.125in}
\centering
\framebox(2,2){\includegraphics[width=1.875in,height=1.875in,keepaspectratio]{infinity_80_gf_2010}}
\caption{A subfigure}
\label{fig:sub1}
\end{subfigure}%
\begin{subfigure}{2.125in}
\centering
\framebox(2,2){\includegraphics[width=1.875in,height=1.875in,keepaspectratio]{Plus80_2010}}
\caption{A subfigure}
\label{fig:sub1}
\end{subfigure}%
\begin{subfigure}{2.125in}
\centering
\framebox(2,2){\includegraphics[width=1.875in,height=1.875in,keepaspectratio]{comfort_achp_Puron}}
\caption{A subfigure}
\label{fig:sub1}
\end{subfigure}
\end{figure}
\blindtext[10]
\chapter{Number two}
\blindtext[10]
\end{document}