我的大学对我的论文有风格要求,似乎是为 MS Word 等用户量身定制的。特别是,章节标题的格式仅在使用大写/粗体/斜体方面与文本的其余部分不同。我需要复制 MS Word 中由以下输入序列生成的章节标题:
- [整个文档双倍行距]
- 第1章 [返回]
- 章节标题 [返回]
- 这是本章的正文....
我唯一没有弄清楚的是如何强制前缀和标题之间的垂直间距为简单的双倍行距,就像文档中其他地方一样。我遗漏了什么?
\documentclass[12pt,letterpaper,oneside,chapterprefix=on]{scrbook}
%Margins
\usepackage[letterpaper,left=1.5in,top=1in,right=1in,bottom=1in]{geometry}
%Type
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage{unicode-math}
\setmathfont{xits-math.otf}
\usepackage[doublespacing]{setspace}
\setlength\parindent{0.5in}
\usepackage{microtype}
\usepackage{lipsum}
%Remove vertical space above/below chapter headings:
%http://tex.stackexchange.com/questions/43087/remove-space-before-chapter-title-with-koma- script-scrbook
\renewcommand*{\chapterheadstartvskip}{\vspace*{-\baselineskip}}
\renewcommand*{\chapterheadendvskip}{\vspace*{0in}}
\setkomafont{disposition}{\normalcolor\rmfamily}
\setkomafont{chapter}{\centering\MakeUppercase}
\begin{document}
\frontmatter
\chapter*{Abstract Title Page}
\chapter*{Abstract}
\chapter*{Copright Page}
\chapter*{Title Page}
\tableofcontents
\listoffigures
\mainmatter
\chapter{Introduction}
\lipsum[1-2]
\appendix
\backmatter
\end{document}
答案1
该类在标题“章节”和标题之间scrbook
引入了额外的\vskip
内容.5\baselineskip
;不幸的是,这个跳过是硬编码的,因此您必须重新定义\@@makechapterhead
以抑制它:
\documentclass[12pt,letterpaper,oneside,chapterprefix=on]{scrbook}
%Margins
\usepackage[letterpaper,left=1.5in,top=1in,right=1in,bottom=1in]{geometry}
%Type
\usepackage{fontspec}
%\setmainfont{Times New Roman}
\usepackage{unicode-math}
\setmathfont{xits-math.otf}
\usepackage[doublespacing]{setspace}
\setlength\parindent{0.5in}
\usepackage{microtype}
\usepackage{lipsum}
%Remove vertical space above/below chapter headings:
%http://tex.stackexchange.com/questions/43087/remove-space-before-chapter-title-with-koma- script-scrbook
\renewcommand*{\chapterheadstartvskip}{\vspace*{-\baselineskip}}
\renewcommand*{\chapterheadendvskip}{\vspace*{0in}}
\renewcommand*{\chapterformat}{\chapappifchapterprefix{\nobreakspace}\thechapter}
\setkomafont{disposition}{\normalcolor\rmfamily}
\setkomafont{chapter}{\centering\MakeUppercase}
\makeatletter
\renewcommand*{\@@makechapterhead}[1]{\chapterheadstartvskip
{%
\setlength{\parindent}{\z@}\setlength{\parfillskip}{\fill}%
\normalfont\sectfont\nobreak\size@chapter{}%
\if@chapterprefix
\let\@tempa\raggedsection
\else
\let\@tempa\@hangfrom
\fi
\@tempa{\ifnum \c@secnumdepth >\m@ne%
\if@mainmatter
\if@chapterprefix
\expandafter\size@chapterprefix
\else
\expandafter\size@chapter
\fi
{\chapterformat}%
\if@chapterprefix
\size@chapterprefix{}\endgraf\nobreak%\vskip\baselineskip
\fi
\fi
\fi
}%
{\raggedsection \interlinepenalty\@M\size@chapter{#1}\par}}%
\nobreak\chapterheadendvskip
}
\makeatother
\begin{document}
\frontmatter
\chapter*{Abstract Title Page}
\chapter*{Abstract}
\chapter*{Copright Page}
\chapter*{Title Page}
\tableofcontents
\listoffigures
\mainmatter
\chapter{Introduction}
\lipsum[1-2]
\appendix
\backmatter
\end{document}
使用该etoolbox
软件包,只需一行修补即可完成此操作\@@makechapterhead
:
\documentclass[12pt,letterpaper,oneside,chapterprefix=on]{scrbook}
%Margins
\usepackage[letterpaper,left=1.5in,top=1in,right=1in,bottom=1in]{geometry}
%Type
\usepackage{fontspec}
%\setmainfont{Times New Roman}
\usepackage{unicode-math}
\setmathfont{xits-math.otf}
\usepackage[doublespacing]{setspace}
\setlength\parindent{0.5in}
\usepackage{microtype}
\usepackage{etoolbox}
\usepackage{lipsum}
%Remove vertical space above/below chapter headings:
%http://tex.stackexchange.com/questions/43087/remove-space-before-chapter-title-with-koma- script-scrbook
\renewcommand*{\chapterheadstartvskip}{\vspace*{-\baselineskip}}
\renewcommand*{\chapterheadendvskip}{\vspace*{0in}}
\renewcommand*{\chapterformat}{\chapappifchapterprefix{\nobreakspace}\thechapter}
\setkomafont{disposition}{\normalcolor\rmfamily}
\setkomafont{chapter}{\centering\MakeUppercase}
\makeatletter
\patchcmd{\@@makechapterhead}{\vskip.5\baselineskip}{}{}{}
\makeatother
\begin{document}
\frontmatter
\chapter*{Abstract Title Page}
\chapter*{Abstract}
\chapter*{Copright Page}
\chapter*{Title Page}
\tableofcontents
\listoffigures
\mainmatter
\chapter{Introduction}
\lipsum[1-2]
\appendix
\backmatter
\end{document}
\setmainfont{Times New Roman}
由于我的系统中没有该字体,所以我注释掉了该行。
作为埃格尔在评论中注意到,根据问题的设置,标题“第 # 章”稍微向左移动;为了纠正这个问题,必须添加以下额外的重新定义:
\renewcommand*{\chapterformat}{\chapappifchapterprefix{\nobreakspace}\thechapter}
答案2
使用 KOMA-Script 类\RedeclareSectionCommand[...]{chapter}
来更改章节标题之前、之后和内部的跳过:
\RedeclareSectionCommand[
afterindent=false,beforeskip=0pt,% afterindent needs version 3.26 or newer
afterskip=0pt,innerskip=0pt
]{chapter}
或者
\RedeclareSectionCommand[
beforeskip=-1sp,
afterskip=0pt,innerskip=0pt
]{chapter}
不要用作\MakeUppercase
字体命令。将其用作\setkomafont
或的第二个参数\addtokomafont
会导致错误。
您可以重新定义\chapterlineswithprefixformat
(用于章节标题chapterprefix=on
)和\chapterlinesformat
(用于章节标题chapterprefix=off
,默认)以获取大写字母的章节标题:
\renewcommand\chapterlineswithprefixformat[3]{%
\ifstr{#1}{chapter}
{\MakeUppercase{#2#3}}
{#2#3}%
}
\makeatletter
\renewcommand\chapterlinesformat[3]{%
\ifstr{#1}{chapter}
{\@hangfrom{#2}{\MakeUppercase{#3}}}
{\@hangfrom{#2}{#3}}%
}
\makeatother
例子
\documentclass[12pt,letterpaper,oneside,chapterprefix=on]{scrbook}
%Margins
\usepackage[letterpaper,left=1.5in,top=1in,right=1in,bottom=1in]{geometry}
%Type
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage{unicode-math}
\setmathfont{xits-math.otf}
\usepackage[doublespacing]{setspace}
\setlength\parindent{0.5in}
\usepackage{microtype}
\usepackage{lipsum}
\RedeclareSectionCommand[
afterindent=false,beforeskip=0pt,% afterindent needs version 3.26 or newer
afterskip=0pt,innerskip=0pt
]{chapter}
\setkomafont{disposition}{\normalcolor\rmfamily}
\setkomafont{chapter}{}
\renewcommand*\raggedchapter{\centering}
\renewcommand\chapterlineswithprefixformat[3]{%
\ifstr{#1}{chapter}
{\MakeUppercase{#2#3}}
{#2#3}%
}
%\makeatletter
%\renewcommand\chapterlinesformat[3]{%
%\ifstr{#1}{chapter}
%{\@hangfrom{#2}{\MakeUppercase{#3}}}
%{\@hangfrom{#2}{#3}}%
%}
%\makeatother
\begin{document}
\frontmatter
\addchap*{Abstract Title Page}
\addchap*{Abstract}
\addchap*{Copright Page}
\addchap*{Title Page}
\tableofcontents
\listoffigures
\mainmatter
\chapter{Introduction}
\lipsum[1-2]
\chapter{Chapter 2}
\lipsum[1-2]
\appendix
\backmatter
\end{document}