我正在使用 scrbook。问题是当我使用 \chapter 时,它会为每个章节创建一个新页面。但我希望所有 3 个章节标题(每个标题都有一个短段落)都在同一页上。而且我不希望它在标题前占用太多空间。我想使用自定义间距。它应该在目录中列出而不带数字。此外,我只希望此行为在此页面上,而不是整个文档。
我感谢您提供的任何帮助。
答案1
我将使用 KOMA-Script 命令\DeclareTOCStyleEntry
并\DeclareNewSectionCommand
在章节级别定义一个具有章节样式的新标题。
\DeclareTOCStyleEntry[
level:=chapter,
indent:=chapter,
beforeskip:=chapter,
numwidth:=chapter
]{chapter}{specialChap}
\DeclareNewSectionCommand[
style=section,
level=\chapternumdepth,
beforeskip=3.5ex plus 1ex minus .2ex,% default section value used
afterskip=2.3ex plus .2ex,% default section value used
afterindent=false,
runin=false,
font=\usekomafont{chapter}
]{specialChap}
\makeatletter
\let\c@specialChap\c@chapter% use chapter counter
\let\lc@specialChap\lc@chapter% use reset list of chapter
\makeatother
对于页眉,您可以使用
\renewcommand{\specialChapmark}[1]\markboth{\specialChapmarkformat#1}{}}
或者如果你加载包scrlayer-scrpage
\usepackage[automark]{scrlayer-scrpage}
\automark*{specialChap}
使用KOMA-Scriptheadings=optiontoheadandtoc
选项nonumber=true
获取未编号的标题。
例子:
\documentclass[headings=optiontoheadandtoc]{scrbook}
\usepackage{lipsum}% only for dummy text
\usepackage{hyperref}
\DeclareTOCStyleEntry[
level:=chapter,
indent:=chapter,
beforeskip:=chapter,
numwidth:=chapter
]{chapter}{specialChap}
\DeclareNewSectionCommand[
style=section,
level=\chapternumdepth,
beforeskip=3.5ex plus 1ex minus .2ex,
afterskip=2.3ex plus .2ex,
afterindent=false,
runin=false,
font=\usekomafont{chapter}
]{specialChap}
\makeatletter
\let\c@specialChap\c@chapter
\let\lc@specialChap\lc@chapter
\makeatother
\renewcommand{\specialChapmark}[1]{\markboth{\specialChapmarkformat#1}{}}
\begin{document}
\tableofcontents
\chapter{Normal chapter}
\lipsum[1]
\section{A section}
\lipsum[2-6]
\cleardoublepage
\specialChap[nonumber=true]{First special chapter}
\lipsum[7]
\specialChap[nonumber=true]{Second special chapter}
\lipsum[8]
\specialChap[nonumber=true]{Third special chapter}
\lipsum[9]
\chapter{Normal chapter}
\lipsum[10-15]
\end{document}
或者
\documentclass[headings=optiontoheadandtoc]{scrbook}
\usepackage{lipsum}% only for dummy text
\usepackage[automark]{scrlayer-scrpage}
\usepackage{hyperref}
\DeclareTOCStyleEntry[
level:=chapter,
indent:=chapter,
beforeskip:=chapter,
numwidth:=chapter
]{chapter}{specialChap}
\DeclareNewSectionCommand[
style=section,
level=\chapternumdepth,
beforeskip=3.5ex plus 1ex minus .2ex,
afterskip=2.3ex plus .2ex,
afterindent=false,
runin=false,
font=\usekomafont{chapter}
]{specialChap}
\makeatletter
\let\c@specialChap\c@chapter
\let\lc@specialChap\lc@chapter
\makeatother
\automark*{specialChap}
\begin{document}
\tableofcontents
\chapter{Normal chapter}
\lipsum[1]
\section{A section}
\lipsum[2-6]
\cleardoublepage
\specialChap[nonumber=true]{First special chapter}
\lipsum[7]
\specialChap[nonumber=true]{Second special chapter}
\lipsum[8]
\specialChap[nonumber=true]{Third special chapter}
\lipsum[9]
\chapter{Normal chapter}
\lipsum[10-15]
\end{document}
答案2
该模板将帮助您入门。
命令\specialChap
将模拟章节标题,使用自定义间距,将条目作为未编号章节插入目录中,但仍保留在同一页。它还将在目录中生成链接。
更新后续问题之后
(1)在“特殊章节”之前添加References
,以检查是否存在从上一章拖入的标题。
(2)hyperref
在目录中添加并生成了正确的链接,References
包括“特殊章节”
编译为 pdflatex + pdflatex + bibtex + pdflatex + pdflatex
\documentclass[open=right]{scrbook}
\usepackage{kantlipsum} % only for dummy text
\usepackage{hyperref}
\newcommand{\specialChap}[1]{% added <<<<<<<<<<<<<<<<
\thispagestyle{plain}
\setkomafont{minisec}{\usekomafont{chapter}}%
\phantomsection% make a link in ToC
\minisec{#1}% simil chapter headings
\vspace*{1ex}% below space
\addcontentsline{toc}{chapter}{#1}% add to ToC at chapter level
}
%%******************************** References
\begin{filecontents*}[overwrite]{\jobname.bib}
@article{Carlson2011,
author = {Carlson, Nicholas},
booktitle = {Businessinsider.com},
title = {{How Many Users Does Twitter REALLY Have?}},
note = {Available online at \url{www.businessinsider.com/chart-of-the-day-how-many-users-does-twitter-really-have-2011-31/3}},
year = {2011},
}
@book{companion94,
author = {Goossens, Michel and Mittelbach, Frank and Samarin, Alexander},
title = {The \LaTeX\ {Companion}},
year = {1994},
edition = 1,
publisher = {Addison-Wesley},
location = {Reading, Mass.},
pagetotal = 528,
}
\end{filecontents*}
%***********************************************
\begin{document}
\tableofcontents
\chapter{This chapter is fine}
1. \kant[1-6]
See \cite{Carlson2011, companion94}.
\cleardoublepage % needed <<<
\phantomsection % make a link in ToC
\addcontentsline{toc}{chapter}{References}% add to ToC at chapter level
\renewcommand{\bibname}{References}%
\bibliographystyle{plain}
\bibliography{\jobname}
\cleardoublepage% needed <<<
\specialChap{First special}
1. \kant[1]
\specialChap{Second special}
9. \kant[9]
\specialChap{Third special}
11. \kant[11]
\chapter{This chapter is also fine}
\kant[4-8]
\end{document}
答案3
回答您的两个问题。
% chapprob.tex SE 637099
\documentclass{scrbook}
\let\saveclear\cleardoublepage
\begin{document}
\tableofcontents
\clearpage
%%% stop chapters starting on another page
\renewcommand{\cleardoublepage}{}
%% unnumbered chapter but added to ToC
\chapter*{Star 1} \addcontentsline{toc}{chapter}{Star 1}
Text
\chapter{Star 2}
Text
\chapter{Star 3}
Text
%% revert to normal chapter location
\let\cleardoublepage\saveclear
\chapter{Regular}
Text
\end{document}
我不知道如何删除目录中的章节编号,也许其他人知道。