我正在尝试格式化文档,scrbook
部分、章节等的标题显示为文章文档的一部分。我怎样才能让它们恢复为与常规scrartcl
`scrbook 标题相同的字体?
梅威瑟:
\documentclass[12pt, a4paper]{scrbook}
\usepackage{xcolor}
\usepackage[sf]{titlesec}
\definecolor{gray75}{gray}{0.65}
\newcommand{\hsp}{\hspace{0pt}}
\titleformat{\chapter}[hang]{\flushleft
\fontseries{b}\fontsize{80}{100}\selectfont}{\fontseries{b}\fontsize{100}{130}\selectfont \textcolor{gray75}\thechapter\hsp}{0pt}{\\ \Huge\bfseries}[]
\titleformat{\part}[hang]{\flushleft
\fontseries{b}\fontsize{80}{100}\selectfont}{\fontseries{b}\fontsize{100}{130}\selectfont \textcolor{gray75}\thechapter\hsp}{0pt}{\\ \Huge\bfseries}[]
\title{Math Handouts}
\author{XYZ}
\date{2021}
\let\cleardoublepage=\clearpage
\begin{document}
\frontmatter
\chapter{Preface}
something
\chapter{Introduction}
somebody
\tableofcontents
\mainmatter
\part{Algebra}
\chapter{Chapter name}
\part{Number Theory}
\chapter{Chapter name}
\end{document}
答案1
不要将包titlesec
与 KOMA-Script 类之一一起使用。
您可以使用选项chapterprefix=true
获取章节的前缀行。您可以更改字体元素chapter
、chapterprefix
和。part
partnumber
例子:
\documentclass[12pt,
%a4paper,% default
open=any,% <- added
chapterprefix,% <- added
numbers=noendperiod
]{scrbook}
\usepackage{fix-cm}
\usepackage{xcolor}
\definecolor{gray75}{gray}{0.65}
\renewcommand*{\chapterformat}{\thechapter\autodot}
\addtokomafont{chapter}{\Huge}
\setkomafont{chapterprefix}{\fontsize{100}{130}\selectfont \color{gray75}}
\renewcommand*{\partformat}{\thepart\autodot}
\setkomafont{partnumber}{\fontsize{100}{130}\selectfont\color{gray75}}
\setkomafont{part}{\normalcolor\Huge}
\renewcommand*{\raggedpart}{\raggedright}
\title{Math Handouts}
\author{XYZ}
\date{2021}
%\let\cleardoublepage=\clearpage% replaced by option open=any
\begin{document}
\frontmatter
\chapter{Preface}
something
\chapter{Introduction}
somebody
\tableofcontents
\mainmatter
\part{Algebra}
\chapter{Chapter name}
\part{Number Theory}
\chapter{Chapter name}
\end{document}
要调整标题前后以及前缀行和文本之间的垂直空间,可以使用选项beforeskip
,afterskip
以及和innerskip
的可选参数中的选项。\RedeclareSectionCommand[...]{chapter}
\RedeclareSectionCommand[...]{part}