我有一份文件,要求章节标题由两部分组成:(1) 章节编号(第 1 章、第一章等)或具有类似功能的任何其他文本,以及 (2) 编号下方的描述性标题,该标题可以很长。我能够将描述性标题放在章节编号下方,并使用以下宏根据我的需求设置其样式:
\documentclass[final]{book}
\usepackage{lipsum}
\def \mylongchapter#1#2{
\chapter*{\centering{\LARGE #1} \\* \textnormal{\Large #2}}
\addcontentsline{toc}{chapter}{#1: #2}
}
\begin{document}
\mylongchapter{Chapter 1}{This Chapter Have Very Interesting and Long Title Below Chapter Number}
\lipsum[11-30]
\end{document}
由此产生了如下结果:
问题:
- 有没有比我做得更好的方法来排版具有这种描述性标题的章节?
- 如何控制(或消除)两行或多行描述性标题之间的间距/间隙(见下图)?
- 如何控制间距第1章和描述性标题?
答案1
您可以尝试@makechapterhead
在书籍类别中重新定义:
\documentclass[final]{book}
\usepackage{lipsum}
%\def \mylongchapter#1#2{
%\chapter*{\centering{\LARGE #1} \\* \textnormal{\Large #2}}
%\addcontentsline{toc}{chapter}{#1: #2}
%}
\makeatletter
\def\@makechapterhead#1{%
\vspace*{50\p@}% margin above chapter number
{\parindent \z@ \centering \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\LARGE\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@% space between chapter number and chapter title
\fi
\fi
\interlinepenalty\@M
\Large \mdseries \centering #1 \par\nobreak
\vskip 40 \p@% space below chapter title
}}
\makeatother
\begin{document}
%\mylongchapter{Chapter 1}{This Chapter Have Very Interesting and Long Title Below Chapter Number}
\chapter{This Chapter Have Very Interesting and Long Title Below Chapter Number}
\lipsum[11-30]
\end{document}
您可以更改三个数值(50\p@
、20\p@
和40 \p@
)来分别调整章节号上方的边距、章节号和章节标题之间的间距以及章节标题下方的间距。请参阅代码中的注释,了解更改这些值的适当位置。
编辑:您可以使用setspace
包来改变间距,如下所示:
\documentclass[final]{book}
\usepackage{lipsum}
\usepackage{setspace} %<========== package to adjust spacing
%\def \mylongchapter#1#2{
%\chapter*{\centering{\LARGE #1} \\* \textnormal{\Large #2}}
%\addcontentsline{toc}{chapter}{#1: #2}
%}
\makeatletter
\def\@makechapterhead#1{%
\vspace*{50\p@}% margin above chapter number
{\parindent \z@ \centering \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\LARGE\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@% space between chapter number and chapter title
\fi
\fi
\interlinepenalty\@M
\Large \mdseries \centering \onehalfspacing #1 \par\nobreak %<========== Add \doublespacing or \onehalfspacing or \singlespacing here
\vskip 40 \p@% space below chapter title
}}
\makeatother
\begin{document}
%\mylongchapter{Chapter 1}{This Chapter Have Very Interesting and Long Title Below Chapter Number}
\chapter{This Chapter Have Very Interesting and Long Title Below Chapter Number}
\lipsum[11-30]
\end{document}
对于\chapter*
,我认为重新定义@makeschapterhead
(注意星号中的“s”)会产生同样的作用。但我怀疑您可以使用其他答案中提到的某个包进行所有这些更改,甚至可能更轻松!
答案2
您可能想要检查该sectsty
包及其\chapterfont
宏。
\documentclass[final]{book}
\usepackage{lipsum,sectsty}
\chapterfont{\nohang\centering\mdseries}
\begin{document}
\chapter[Long-Titled Chapter Header]{A Very Interesting and Long Title Below the Chapter Number}
\lipsum[1-3]
\end{document}
答案3
您可以完全控制该titlesec/titleps
包:
\documentclass[11pt, final]{book}
\usepackage[utf8]{inputenc}
\usepackage{fourier, heuristica}
\usepackage{ifthen}
\usepackage{lipsum}
\usepackage{setspace}
\usepackage[clearempty, toctitles, newlinetospace, pagestyles]{titlesec}%explicit,
\titleformat{\chapter}[display]{\centering}{\LARGE\bfseries\chaptername~\thechapter}{1\baselineskip} {\onehalfspacing\Large}[\thispagestyle{basic}]
\titlespacing{\chapter}{0pt}{-2\baselineskip}{6\baselineskip}
\setheadrule{3pt}
\newpagestyle{basic}{%
\setfoot{}{\thepage}{}}
\renewpagestyle{plain}{%
\widenhead[1.5em][0pt]{0pt}{1.5em}
%\ifthechapter{\setheadrule{0pt}}{\setheadrule{0.4pt}}
\headrule
\sethead[][\small\scshape\chaptertitle][]{}{\small\itshape\sectiontitle}{}
\setfoot{}{\thepage}{}
\headrule
}
\pagestyle{plain}
\begin{document}
\chapter{This Chapter Has a Very Interesting and Long Title Below Chapter Number}
\section{First Section}
\lipsum[1-5]
\section{Second Section}
\lipsum[6-10]
\end{document}
\documentclass[11pt, final]{book}
\usepackage[utf8]{inputenc}
\usepackage{fourier, heuristica}
\usepackage{ifthen}
\usepackage{lipsum}
\usepackage{setspace}
\usepackage[clearempty, toctitles, newlinetospace, pagestyles]{titlesec}%explicit,
\titleformat{\chapter}[display]{\centering}{\LARGE\bfseries\chaptername~\thechapter}{1\baselineskip} {\onehalfspacing\Large}[\thispagestyle{basic}]
\titlespacing{\chapter}{0pt}{-2\baselineskip}{6\baselineskip}
\setheadrule{3pt}
\newpagestyle{basic}{%
\setfoot{}{\thepage}{}}
\renewpagestyle{plain}{%
\widenhead[1.5em][0pt]{0pt}{1.5em}
%\ifthechapter{\setheadrule{0pt}}{\setheadrule{0.4pt}}
\headrule
\sethead[][\small\scshape\chaptertitle][]{}{\small\itshape\sectiontitle}{}
\setfoot{}{\thepage}{}
\headrule
}
\pagestyle{plain}
\begin{document}
\chapter{This Chapter Has a Very Interesting and Long Title Below Chapter Number}
\section{First Section}
\lipsum[1-5]
\section{Second Section}
\lipsum[6-10]
\end{document}