我希望我的目录中包含以下内容
I 第一章
I.1 第一节
I.2 第二节 II 第二章
II.1 第一节
II.2 第二节贡献
贡献 I:第一篇论文的标题 % 这可能是外部包含的 pdf
贡献 II:第一篇论文的标题
在我的后续 MWE 中,我更改了贡献部分中章节的名称,并将贡献标题作为选项放在目录中,但我没有使用例如“贡献 I:其标题”,而是使用了“I 贡献 I:其标题”。
\documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\RequirePackage{etoolbox}
\RequirePackage{xparse}
\RequirePackage{scrhack} %
\RequirePackage[markcase=used]{scrlayer-scrpage}
\addtokomafont{pagenumber}{\oldstylenums}
%\providepairofpagestyles{thesisSimple}{%
\clearpairofpagestyles%
\automark[chapter]{chapter} %\automark[right side]{left side}
\ihead{\headmark}% Inner header
\ohead[\pagemark]{\pagemark}% Outer header
%vll
\setkomafont{pagehead}{\bfseries}
\renewcommand\thechapter{\Roman{chapter}}
\usepackage[Conny]{fncychap} %
\ChNameAsIs
\ChTitleAsIs
\makeatletter
\def\@makechapterhead#1{%
\vspace*{-20\p@}
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\DOCH
\fi
\fi
\interlinepenalty\@M
\if@mainmatter %
\DOTI{#1}%
\else%
\DOTIS{#1}%
\fi
}}
\def\@makeschapterhead#1{%
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\DOTIS{#1}
\vskip -20\p@
}}
\makeatother
%========================
\usepackage{hyperref}
\usepackage[autostyle=true]{csquotes}
\usepackage{lipsum}
\begin{document}
\tableofcontents
\chapter{First chapter}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1]
\chapter{Sec. chapter}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1-4]
\addtocontents{toc}{\bigskip \textbf{\large Contributions}\par}
\setcounter{chapter}{0}
\renewcommand{\chaptername}{Contribution}
\chapter[Contribution I: Paper title]{First paper's title}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1-4]
\chapter[Contribution II: Paper title]{Second contribution}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1-4]
\end{document}
PS:我尝试了答案中给出的方法,但没有成功这个问题
答案1
scrbook
以下是使用 KOMA-Script 类但不使用包的建议fncychap
:
\documentclass[10pt,a4paper]{scrbook}[2017/09/07]% needs version 3.24 or newer
\usepackage[utf8]{inputenc}
\usepackage[markcase=used]{scrlayer-scrpage}
\addtokomafont{pagenumber}{\oldstylenums}
\clearpairofpagestyles%
\automark[chapter]{chapter}
\ihead{\headmark}
\ohead*{\pagemark}
\setkomafont{pagehead}{\bfseries}
\renewcommand\thechapter{\Roman{chapter}}
\KOMAoptions{chapterprefix,numbers=noenddot,egregdoesnotlikesansseriftitles}
\renewcommand\raggedchapter{\centering}
\newlength{\ChapterRuleWidth}\setlength{\ChapterRuleWidth}{2pt}
\RedeclareSectionCommand[
beforeskip=-1sp,
expandtopt,
innerskip=.5\baselineskip,
afterskip=60pt,
font=\normalfont\Huge,
prefixfont=\bfseries
]{chapter}
\newcaptionname{english}{\contributionname}{Contribution}
\DeclareNewSectionCommand[
style=chapter,
level=\chapternumdepth,
toclevel=\chaptertocdepth,
tocbeforeskip=1em plus 1pt,
tocindent=0pt,
tocnumwidth=1.5em,
tocdynnumwidth,
tocentryformat=\usekomafont{chapterentry},
tocentrynumberformat=\contributiontocnumber,
tocentrypagenumberformat=\usekomafont{chapterentry},
toclinefill=\hfill
]{contribution}
\renewcommand\thecontribution{\Roman{contribution}}
\newcommand*\contributiontocnumber[1]{\contributionname\ #1:\hfill}
\renewcommand*\contributionformat{\contributionname\nobreakspace\thecontribution\autodot}
\renewcommand*\contributionmarkformat{\contributionname\ \thecontribution\autodot\enskip}
\automark*[contribution]{contribution}
\makeatletter
\renewcommand\chapterlineswithprefixformat[3]{%
\IfArgIsEmpty{#2}{}{{%
\normalsize\rule{\linewidth}{3\ChapterRuleWidth}\\*[-.5\baselineskip]%
\rule{\linewidth}{\ChapterRuleWidth}\par\nobreak
}#2}%
{\normalsize\rule{\linewidth}{\ChapterRuleWidth}\par\nobreak}
#3
\IfArgIsEmpty{#2}{\vskip -20pt}{}%
}
\makeatother
\newcounter{defaulttocdepth}
\newcommand\StartContributions{%
\cleardoublepage
\RedeclareSectionCommand[counterwithin=contribution]{section}%
\addxcontentsline{toc}{part}{Contributions}%
\addtocontents{toc}{\protect\value{tocdepth}=\contributionnumdepth}%
}
\setkomafont{partentrypagenumber}{\nullfont}
\newcommand\EndContributions{%
\RedeclareSectionCommand[counterwithin=chapter]{section}%
\addtocontents{toc}{\protect\value{tocdepth}=\the\value{tocdepth}}%
}
\usepackage{hyperref}
\usepackage{lipsum}% only for dummy text
\begin{document}
\tableofcontents
\chapter{First chapter}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1]
\chapter{Sec. chapter}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1-4]
\StartContributions
\contribution{First paper's title}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1-4]
\contribution{Second contribution}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1-4]
\EndContributions
\chapter{Test}
\section{Test}
\lipsum
\end{document}
请注意,上述代码至少需要 KOMA-Script 版本 3.24。更新:如果您使用 KOMA-Script 版本 3.39 或更新版本,请egregdoesnotlikesansseriftitles
用新的类选项替换弃用的选项sfdefaults=false
。
如果你想要/必须使用 3.21、3.22 或 3.23 版本之一,请添加
beforeskip=-1sp,
innerskip=.5\baselineskip,
afterskip=60pt,
font=\normalfont\Huge,
prefixfont=\bfseries,
pagestyle=plain,
的选项\DeclareNewSectionFormat[...]{contribution}
。
结果:
但也可以tocbasic
与另一个类一起使用以获得所需的结果:
添加
\usepackage{tocbasic}
\newcommand*\Contribution{%
\renewcommand*{\chaptername}{Contribution}%
\setcounter{chapter}{0}%
\addtocontents{toc}{%
\bigskip \noindent\textbf{\large Contributions}\protect\par
\DeclareTOCStyleEntry
[entrynumberformat=\nullfont,numwidth=0pt,pagenumberformat=\textbf]
{tocline}{chapter}%
\protect\value{tocdepth}=0%
}%
\renewcommand\chaptermarkformat{}%
}
到序言部分并使用\Contribution
到文档正文部分。这也应该适用于您在评论中提到的特殊类。假设不需要切换回正常章节,我没有像在第一个示例中那样为贡献的结束定义命令。但该示例也更正了标题条目。
代码:
\documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\RequirePackage{etoolbox}
\RequirePackage{xparse}
\RequirePackage{scrhack} %
\RequirePackage[markcase=used]{scrlayer-scrpage}
\addtokomafont{pagenumber}{\oldstylenums}
%\providepairofpagestyles{thesisSimple}{%
\clearpairofpagestyles%
\automark[chapter]{chapter} %\automark[right side]{left side}
\ihead{\headmark}% Inner header
\ohead[\pagemark]{\pagemark}% Outer header
%vll
\setkomafont{pagehead}{\bfseries}
\renewcommand\thechapter{\Roman{chapter}}
\usepackage[Conny]{fncychap} %
\ChNameAsIs
\ChTitleAsIs
\makeatletter
\def\@makechapterhead#1{%
\vspace*{-20\p@}
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\DOCH
\fi
\fi
\interlinepenalty\@M
\if@mainmatter %
\DOTI{#1}%
\else%
\DOTIS{#1}%
\fi
}}
\def\@makeschapterhead#1{%
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\DOTIS{#1}
\vskip -20\p@
}}
\makeatother
%========================
\usepackage{tocbasic}
\newcommand*\Contribution{%
\renewcommand*{\chaptername}{Contribution}%
\setcounter{chapter}{0}%
\addtocontents{toc}{%
\bigskip \noindent\textbf{\large Contributions}\protect\par
\DeclareTOCStyleEntry
[entrynumberformat=\nullfont,numwidth=0pt,pagenumberformat=\textbf]
{tocline}{chapter}%
\protect\value{tocdepth}=0%
}%
\renewcommand\chaptermarkformat{}%
}
\usepackage[hypertexnames=false]{hyperref}
\usepackage[english]{babel}
\usepackage[autostyle=true]{csquotes}
\usepackage{lipsum}
\begin{document}
\tableofcontents
\chapter{First chapter}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1]
\chapter{Sec. chapter}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1-4]
\Contribution
\chapter[Contribution I: Paper title]{First paper's title}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1-4]
\chapter[Contribution II: Paper title]{Second contribution}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1-4]
\end{document}
更新(贡献后的附录)
在评论中,OP 要求将附录章节改回正常的条目格式。
然后我会用
\usepackage{tocbasic}
\newcommand*\Contribution{%
\renewcommand*{\chaptername}{Contribution}%
\setcounter{chapter}{0}%
\addtocontents{toc}{%
\bigskip \noindent\textbf{\large Contributions}\protect\par
\DeclareTOCStyleEntry
[entrynumberformat=\nullfont,numwidth=0pt]
{tocline}{chapter}%
\protect\value{tocdepth}=0%
}%
\renewcommand\chaptermarkformat{}%
}
\xapptocmd\appendix{%
\addtocontents{toc}{%
\defaultchaptertocstyle
\protect\value{tocdepth}=\the\value{tocdepth}%
}%
\let\chaptermarkformat\defaultchaptermarkformat
}
\newcommand*\defaultchaptertocstyle{%
\DeclareTOCStyleEntry[entrynumberformat=\bfseries,numwidth=1.5em,pagenumberformat=\textbf]
{tocline}{chapter}%
}
\AtBeginDocument{%
\let\defaultchaptermarkformat\chaptermarkformat
\defaultchaptertocstyle
}
代码:
\documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\RequirePackage{xparse}% loads etoolbox
\RequirePackage{scrhack} %
\RequirePackage[markcase=used]{scrlayer-scrpage}
\addtokomafont{pagenumber}{\oldstylenums}
%\providepairofpagestyles{thesisSimple}{%
\clearpairofpagestyles%
\automark[chapter]{chapter} %\automark[right side]{left side}
\ihead{\headmark}% Inner header
\ohead[\pagemark]{\pagemark}% Outer header
%vll
\setkomafont{pagehead}{\bfseries}
\renewcommand\thechapter{\Roman{chapter}}
\usepackage[Conny]{fncychap} %
\ChNameAsIs
\ChTitleAsIs
\makeatletter
\def\@makechapterhead#1{%
\vspace*{-20\p@}
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\DOCH
\fi
\fi
\interlinepenalty\@M
\if@mainmatter %
\DOTI{#1}%
\else%
\DOTIS{#1}%
\fi
}}
\def\@makeschapterhead#1{%
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\DOTIS{#1}
\vskip -20\p@
}}
\makeatother
%========================
\usepackage{tocbasic}
\newcommand*\Contribution{%
\renewcommand*{\chaptername}{Contribution}%
\setcounter{chapter}{0}%
\addtocontents{toc}{%
\bigskip \noindent\textbf{\large Contributions}\protect\par
\DeclareTOCStyleEntry
[entrynumberformat=\nullfont,numwidth=0pt]
{tocline}{chapter}%
\protect\value{tocdepth}=0%
}%
\renewcommand\chaptermarkformat{}%
}
\xapptocmd\appendix{%
\addtocontents{toc}{%
\defaultchaptertocstyle
\protect\value{tocdepth}=\the\value{tocdepth}%
}%
\let\chaptermarkformat\defaultchaptermarkformat
}
\newcommand*\defaultchaptertocstyle{%
\DeclareTOCStyleEntry[entrynumberformat=\bfseries,numwidth=1.5em,pagenumberformat=\textbf]
{tocline}{chapter}%
}
\AtBeginDocument{%
\let\defaultchaptermarkformat\chaptermarkformat
\defaultchaptertocstyle
}
\usepackage[hypertexnames=false]{hyperref}
\usepackage[english]{babel}
\usepackage[autostyle=true]{csquotes}
\usepackage{lipsum}
\begin{document}
\tableofcontents
\chapter{First chapter}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1]
\chapter{Sec. chapter}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1-4]
\Contribution
\chapter[Contribution I: Paper title]{First paper's title}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1-4]
\chapter[Contribution II: Paper title]{Second contribution}
\lipsum[1]
\section{First section}
\lipsum[1]
\section{Sec. section}
\lipsum[1-4]
\appendix
\chapter{First appendix}
\section{An appendix section}
\lipsum
\section {Second appendix section}
\lipsum
\end{document}