我想在每个章节前插入一页,并标出章节标题。如何在 latex 中实现此目的...?
我的LaTeX文档的结构如下:
documentclass[a4paper,11pt]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,graphicx,color,algorithm,float,caption,mathtools}
\usepackage{url,rotating,multirow}
\usepackage{algpseudocode,pdfpages}
\usepackage[normalem]{ulem}
\usepackage{breqn}
\DeclarePairedDelimiter{\ceil}{\lceil}{\rceil}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[HL]{\leftmark}
\fancyfoot[C] {\thepage}
\renewcommand{\headrulewidth}{1pt}
\begin{document}
\cleardoublepage
\pagenumbering{gobble}
\includepdf[pages={-}]{certificate/certi.pdf}
\tableofcontents
\listoffigures
\listoftables
\cleardoublepage
\pagenumbering{arabic}
\include{abstract/abstract}
\include{introduction/intro}
\include{survey/survey}
\include{chapter1/chapter1}
\include{chapter2/chapter2}
\include{chapter3/chapter3}
\include{chapter4/chapter4}
\include{chapter5/chapter5}
\include{results/results}
\include{conclusion/conclusion}
%references will go here
\renewcommand{\bibname}{References}
\bibliographystyle{plain}
\bibliography{References/references}
\end{document}
我希望在每一章开始前插入一页,其中包含章节标题...例如,如果第一章名为“某些章节名称”从第 10 页开始,那么我想在第 10 页之前插入一页,其中包含文本“第 1 章某些章节名称
答案1
重新定义章节命令以在之前执行一些开始代码,最简单的形式是,您必须使用clearpage
之前,使用旧的页面样式,然后使用普通的页面样式并添加页面代码,然后切换回旧的花式页面样式。
由于该命令有\chapter[]{}
多种形式,因此必须同时捕获这两种形式。\chapter{}
\chapter
\documentclass[a4paper,11pt]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,graphicx,color,algorithm,float,caption,mathtools}
\usepackage{url,rotating,multirow}
\usepackage{algpseudocode,pdfpages}
\usepackage[normalem]{ulem}
\usepackage{breqn}
\usepackage{blindtext}
\DeclarePairedDelimiter{\ceil}{\lceil}{\rceil}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[HL]{\leftmark}
\fancyfoot[C] {\thepage}
\let\LaTeXStandardChapter\chapter%
\newcommand{\chapterstartpage}[1]{%
\clearpage% Clearpage first, then use pagestyle plain
\pagestyle{plain}%
\addtocounter{chapter}{1}%
\begingroup
\centering%
\Huge \textbf{\chaptername~\thechapter}%%
\addtocounter{chapter}{-1}%
%% Add more space here, do more formatting also here
\vspace{\baselineskip}%
\textbf{#1}%
\endgroup
\clearpage
\pagestyle{fancy}%
}%
\makeatletter
\newcommand{\chapter@noopt}[1]{%
\chapterstartpage{#1}%
\LaTeXStandardChapter{#1}%
}%
\newcommand{\chapter@opt}[2][]{%
\chapterstartpage{#2}%
\LaTeXStandardChapter[#1]{#2}%
}%
\newcommand{\unstarredchapter}{%
\@ifnextchar[{\chapter@opt}{\chapter@noopt}%
}%
\newcommand{\starredchapter}[1]{%
\LaTeXStandardChapter*{#1}
}%
\renewcommand{\chapter}{%
\@ifstar{\starredchapter}{\unstarredchapter}%
}%
\makeatother
\renewcommand{\headrulewidth}{1pt}
\begin{document}
\cleardoublepage
\pagenumbering{gobble}
%\includepdf[pages={-}]{certificate/certi.pdf}
\tableofcontents
\listoffigures
\listoftables
\cleardoublepage
\pagenumbering{arabic}
\chapter{Some sophisticated chapter}%
\chapter{Another sophisticated chapter}%
\blindtext[5]
\chapter{Yet another sophisticated chapter}%
\blindtext[5]
%\include{abstract/abstract}
%\include{introduction/intro}
%\include{survey/survey}
%\include{chapter1/chapter1}
%\include{chapter2/chapter2}
%\include{chapter3/chapter3}
%\include{chapter4/chapter4}
%\include{chapter5/chapter5}
%\include{results/results}
%\include{conclusion/conclusion}
%references will go here
%\renewcommand{\bibname}{References}
%\bibliographystyle{plain}
%\bibliography{References/references}
\end{document}
答案2
主题的另一个变体,用于与其标准变体一起xparse
重新定义。如果愿意,请调整并享受。\chapter
我假设在某些情况下您可能希望恢复到 的先前定义\chapter
。我已使用目录来演示实现此目的的一种方法。
\documentclass[a4paper, 11pt]{report}
\usepackage{xparse, adforn}
\let\origchapter\chapter
\DeclareDocumentCommand\chapter{s o m}{%
\IfNoValueTF{#2}{\def\myshortchtitle{#3}}{\def\myshortchtitle{#2}}%
\clearpage
\thispagestyle{empty}%
\vspace*{.25\textheight}%
{\centering
\stepcounter{chapter}%
\LARGE\bfseries
\IfBooleanTF{#1}{%
\phantom{\chaptername\ \thechapter}}{%
\chaptername\ \thechapter}\par
\vskip .025\textheight
\Huge #3\par
\adforn{22}\adforn{50}\par}
\addtocounter{chapter}{-1}%
\clearpage
\IfBooleanTF{#1}{%
\origchapter*{#3}}{%
\origchapter[\myshortchtitle]{#3}}}
\begin{document}
\let\oldchapter\chapter% if you don't want the ToC to have a page before it
\let\chapter\origchapter% if you don't want the ToC to have a page before it
\tableofcontents
\let\chapter\oldchapter% if you don't want the ToC to have a page before it
\chapter*[Short Starred Title]{A Starred Chapter}
\chapter{A Chapter}
\chapter{Another Chapter}
\chapter[Short Title]{An Exceptionally Long Chapter Title}
\end{document}
答案3
\chapter
可以重新定义以捕获参数(由于星号形式和可选参数,因此并不简单)。
起点:
\documentclass[a5paper,11pt]{report}
\usepackage{color}
\usepackage{lipsum}
\makeatletter
\newcommand*{\SavedChapter}{}
\let\SavedChapter\chapter
\renewcommand*{\chapter}{%
\clearpage
% \if@openright\cleardoublepage\else\clearpage\fi % \chapter/report.cls
\secdef\NormalChapter\StarChapter
}
\newcommand*{\NormalChapter}{}
\def\NormalChapter[#1]#2{%
\stepcounter{chapter}%
\ChapterPage[\@chapapp\space\thechapter]{#2}%
\addtocounter{chapter}{-1}%
\SavedChapter[{#1}]{#2}%
}
\newcommand*{\StarChapter}[1]{%
\ChapterPage{#1}%
\SavedChapter*{#1}%
}
\newcommand*{\ChapterPage}[2][]{%
\begingroup
\color{red}
\def\ChapterTemp{#1}%
\ifx\ChapterTemp\@empty
\@makeschapterhead{#2}%
\else
\@makechapterhead{#2}%
\fi
\endgroup
}
\makeatother
\begin{document}
\tableofcontents
\chapter{Introduction}
\lipsum[2]
\end{document}