我想在书籍类别中添加一个不带编号的章节。它也应该出现在目录中。但是,目前的章节规则似乎不允许这样做。例如,在章节中,出现了前几章的标题。我想我必须修改命令 \chapter*[]{}。但我不知道怎么做。附件中,您找到了 MWE。非常感谢。
\documentclass{book}
\begin{document}
\tableofcontents
\chapter[Initial stuff]{Initial stuff}
Interesting stuff.
\clearpage
\chapter*[General summary]{General summary}
\addcontentsline{toc}{chapter}{Summary and overall conclusion}
Interesting stuff.
\clearpage
We conclude.
\end{document}
编辑1:
我意识到我的 MWE 中缺少了一些东西。章节定义。这就是 Pieter 的回复无法正常工作的原因。我很抱歉。附件中您可以找到完整的 MWE。由于有些人要求澄清,可能是由于缺少部分内容,我会再次解释。我的章节定义是这样的,使用后,章节的标题以及部分会交替出现。这很好用。但是,如果我使用\chapter*[]{}
,它就不再起作用了。相反,我们在标题中看到“2.A ADDITIONAL TABLES”。我想看到章节标题。我希望这能澄清这个问题。我相信这是关键部分:
\titleformat{\chapter}[display]
{\Large\sffamily}
{\vspace{1pc}\LARGE\MakeUppercase{\chaptertitlename} \thechapter}
{1pc}
{\titlerule\vspace{1pc}\Huge}
谢谢。
完整 MWE:
\documentclass[12pt]{book}
\renewcommand{\baselinestretch}{1.5}
\usepackage[toc,page]{appendix}
\usepackage{array}
\usepackage{amsmath,amsthm,verbatim,amssymb,amsfonts,amscd, graphicx}
%\usepackage[toc,page]{appendix}
\usepackage{booktabs}
%\usepackage{caption}
%\usepackage{cite}
\usepackage{eurosym}
\usepackage{float}
%\usepackage{graphics}
%\usepackage{hyperref}
\usepackage{lscape}
\usepackage{multirow}
\usepackage{natbib}
\usepackage{natbib}
%\bibliographystyle{rusnat}
%\usepackage[]{natbib}
%\usepackage[authordate]{biblatex-chicago}
%\usepackage[authordate]{biblatex-chicago}
\setcitestyle{sort&compress,authoryear,open={(},close={)}}
\usepackage{rotating}
\usepackage{setspace}
\usepackage{subcaption}
%\usepackage{subfig}
\usepackage{threeparttable}
\usepackage{xcolor}
\usepackage[tableposition=top]{caption}
\usepackage[section]{placeins}
\usepackage[multiple]{footmisc}
\usepackage[left=2.5cm, right=2.5cm, top=2.5cm, bottom=2.5cm]{geometry}
\usepackage{pifont}
\usepackage[acronym]{glossaries}
\makeglossaries
\usepackage{longtable} % for 'longtable' environment
\usepackage{pdflscape} % for 'landscape' environment
\usepackage[hyphens]{url}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=black,
filecolor=black,
urlcolor=black,
citecolor=blue,
}
\usepackage{fancyhdr}
\pagestyle{fancy}
%\usepackage{fancychap}
\usepackage{titlesec}
\usepackage{lipsum}
\usepackage{etoolbox}
\usepackage{dsfont}
\usepackage{makecell}
\titleformat{\chapter}[display]
{\Large\sffamily}
{\vspace{1pc}\LARGE\MakeUppercase{\chaptertitlename} \thechapter}
{1pc}
{\titlerule\vspace{1pc}\Huge}
\newcommand{\chapterstarmark}[1]{\markboth{#1}{#1}}
\newcommand{\chapterthanksmark}{%
\renewcommand{\thefootnote}{$\ast$}%
\footnotemark%
}
\newcommand{\chapterthanksnote}[1]{%
\renewcommand{\thefootnote}{$\ast$}%
\addtocounter{footnote}{-1}%
\footnotetext{#1}%
\renewcommand{\thefootnote}{\arabic{footnote}}% <-- restore footnote numbering
}
%[\newpage] % creates the new page
\usepackage{tabularx}
% *****************************************************************
% Custom subcaptions
% *****************************************************************
% Note/Source/Text after Tables
\newcommand{\figtext}[1]{
\vspace{1ex}
\captionsetup{justification={justified}, font={footnotesize,singlespacing}}
\caption*{\hspace{6pt}\hangindent=1.5em #1}
}
\newcommand{\fignote}[1]{\figtext{\emph{Note:~}~#1}}
\newcommand{\figsource}[1]{\figtext{\emph{Source:~}~#1}}
% Add significance note with \starnote
\newcommand{\starnote}{\figtext{* p $<$ 0.1, ** p $<$ 0.05, *** p $<$ 0.01.}}
\newcommand{\tablefont}{\fontsize{10pt}{10pt}\selectfont\centering}
\newcommand{\tablefonttwo}{\fontsize{8pt}{10pt}\selectfont\centering}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
% *****************************************************************
% Cnew column types
% *****************************************************************
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\defcitealias{bmg2020}{Federal Ministry of Health, 2020}
\defcitealias{WHO2020}{WHO, 2020}
\defcitealias{BAMF2019}{BAMF, 2019}
\defcitealias{CDC2020}{CDC, 2020}
\defcitealias{RKI2020a}{RKI, 2020a}
\defcitealias{ba2020}{BA, 2020}
\defcitealias{Lancet2020}{The Lancet Global Health, 2020}
\defcitealias{UNHCR1951}{UNHCR, 1951}
\defcitealias{CSTE2017}{\scshape CSTE (2017)}
\newcommand{\ie}{\textit{i}.\textit{e}., }
\newcommand{\eg}{\textit{e}.\textit{g}., }
\def\chapterthanks#1{\renewcommand{\thefootnote}{$\heartsuit$}%
\addtocounter{footnote}{-1}%
\footnote{#1}}
\makeatletter
\patchcmd{\@maketitle}{\newpage}{}{}{}
\renewcommand*\l@figure{\@dottedtocline{1}{1.5em}{3em}} % modified.
\let\l@table\l@figure
\makeatother
\fancyfoot{}
\fancyhead[RO,LE]{\thepage}
\fancyhead[LO]{\leftmark}
\fancyhead[RE]{\rightmark}
\AtBeginEnvironment{subappendices}{%
\chapter*{Appendix}
\addcontentsline{toc}{chapter}{Appendices}
\counterwithin{figure}{section}
\counterwithin{table}{section}
}
\AtEndEnvironment{subappendices}{%
\counterwithout{figure}{section}
\counterwithin{figure}{chapter}
\counterwithout{table}{section}
\counterwithin{table}{chapter}
}
\let\cleardoublepage=\clearpage
\begin{document}
\begin{titlepage}
\begin{center}
\vspace*{1cm}
{\LARGE Awesome stuff}
\vspace{2cm}
{\Large stuffy stuff}
\vspace{2cm}
{\Large More stuffy stuff
\vfill
%\includegraphics[width=0.4\textwidth]{university}
Authored by me}
\end{center}
\end{titlepage}
\tableofcontents
\listoffigures
\listoftables
\chapter[Initial stuff]{Initial stuff}
Interesting stuff.
\section{test}
\begin{table}[]
\caption{Test 1\label{tab:test1}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 & \\
5 & 6 & 7 & 8 & \\
& & & & \\
& & & &
\end{tabular}
\end{table}
\clearpage
more text
\clearpage
way more text
\begin{subappendices}
\section{Additional tables}
\begin{table}[]
\caption{Test 2\label{tab:test2}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 & \\
5 & 6 & 7 & 8 & \\
& & & & \\
& & & &
\end{tabular}
\end{table}
\end{subappendices}
\chapter[Initial stuff 2]{Initial stuff}
Interesting stuff 2.
\section{test 2}
\begin{table}[]
\caption{Test 3\label{tab:test3}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 & \\
5 & 6 & 7 & 8 & \\
& & & & \\
& & & &
\end{tabular}
\end{table}
\begin{subappendices}
\section{Additional tables}
\begin{table}[]
\caption{Test 4\label{tab:test4}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 & \\
5 & 6 & 7 & 8 & \\
& & & & \\
& & & &
\end{tabular}
\end{table}
\end{subappendices}
\chapter*[General summary]{General summary}\addcontentsline{toc}{chapter}{Summary and overall conclusion}
Interesting stuff.
\clearpage
We conclude.
\end{document}
最后编辑和结论:
Pieter 的解决方案做到了。必须将其添加到序言中,并用 Pieter 的版本替换 chapterstarmark。效果很好。所有麻烦都是我造成的。
答案1
以下是重新定义 的代码\chapter
,以便\chapter*
接受可选参数。如果存在可选参数,它将为标题生成标记。如果不存在,则不会发生任何变化,因此目录、索引、参考书目等中的使用不会受到影响。因为对于\chapter*
,章节编号没有意义,所以该命令不用于\chaptermark
生成标记,但引入了一个与未加星号的章节\chapterstarmark
类似的新命令\chaptermark
。
\let\originalchapter\chapter
\RenewDocumentCommand{\chapter}{som}{%
\IfBooleanTF{#1}
{% \chapter*
\originalchapter*{#3}
\IfNoValueF{#2}
{\chapterstarmark{#2}}%
}%
{% normal \chapter
\IfNoValueTF{#2}
{\originalchapter{#3}}
{\originalchapter[#2]{#3}}%
}%
}
\newcommand{\chapterstarmark}[1]{\markboth{#1}{}}