书籍(小说)布局

书籍(小说)布局

如果您有任何建议,我将不胜感激。我想使用 Mathilde 字体格式化章节标题。但是,我收到以下错误:

File ended while scanning use of \scr@ttl@@extract.
Usage of package `titlesec' together(scrbook) with a KOMA-Script class is not recommended.
Non standard sectioning command detected(titlesec) Using default spacing and no format.
Non standard sectioning command detected(titlesec) Using default spacing and no format.
Activating an ugly workaround for a missing(scrbook) feature of package `titles`

除了错误之外,我注意到该部分的字体没有更改为 Mathilde。

我附加了一个可以说明该问题的 MWE。

\documentclass[11pt,english,british,twoside,openany]{scrbook}
\usepackage[showframe]{geometry} % to show margins
\usepackage[baseline=18pt,lines=33]{grid}
\usepackage{lineno} % to show line numbers
\usepackage{lipsum} % to show dummy text 
\setkomafont{section}{\fontsize{40}{45}\selectfont\fontspec{Mathilde}}
\usepackage{titlesec}%Add space above chapter titles
\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}     {\normalsize}
\titlespacing*{\chapter}{0pt}{25pt}{1pt}%Second number changes space amount
\begin{document}
\linenumbers % show line numbers
\section*{SECTION}
\vspace{0 mm}
\lipsum[1-50] % dummy text
\end{document}

答案1

titlesec如果与 KOMA-Script 类一起使用,则会收到警告。但错误消息

扫描使用 \scr@ttl@@extract 时文件结束。

是由以下因素共同引起的titlesec grid使用 KOMA-Script 类。请注意,grid重新定义了命令\section\subsection以及\subsubsection。从grid.sty

%%  Sections
%
\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-.999\baselineskip}%
                                   {0.001\baselineskip}%
                                   {\bfseries\mathversion{bold}}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                   {\baselineskip}%
                                   {-.35\baselineskip}%
                                   {\bfseries\unskip}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                   {\baselineskip}%
                                   {-.35\baselineskip}%
                                   {\itshape\unskip}}

这也是为什么你的章节标题的字体不能通过\addtokomafont或来改变的原因\setkomafont。你必须使用

\RedeclareSectionCommand[
  font=\mathilde\fontsize{40}{45}\selectfont
]{section}

加载中grid。但是随后,节标题的 KOMA-Script 定义“获胜”。

我不知道你为什么要加载grid。但这里有一个建议,titlesec

\documentclass[openany,chapterprefix]{scrbook}
\usepackage[showframe]{geometry} % to show margins

\usepackage[baseline=18pt,lines=33]{grid}
\usepackage{lineno} % to show line numbers
\usepackage{lipsum} % to show dummy text 

\usepackage{fontspec}
\newfontfamily\mathilde{Mathilde}

\RedeclareSectionCommand[
  prefixfont=\normalfont\huge\bfseries,
  font=\normalsize\rmfamily,
  beforeskip=38pt,
  innerskip=20pt,
  afterskip=1pt
]{chapter}

\RedeclareSectionCommand[
  font=\mathilde\fontsize{40}{45}\selectfont
]{section}


\begin{document}
\linenumbers % show line numbers
\chapter{Test}
\section{SECTION}
\lipsum[1-50]
\end{document}

在此处输入图片描述


如果你确实想使用包titlesec(不推荐),请加载它 grid

\documentclass[openany,chapterprefix]{scrbook}
\usepackage[showframe]{geometry} % to show margins

\usepackage{titlesec}%Add space above chapter titles

\usepackage[baseline=18pt,lines=33]{grid}
\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\normalsize}
\titlespacing*{\chapter}{0pt}{25pt}{1pt}%Second number changes space amount
\usepackage{lineno} % to show line numbers
\usepackage{lipsum} % to show dummy text 

\usepackage{fontspec}
\newfontfamily\mathilde{Mathilde}

\RedeclareSectionCommand[
  font=\mathilde\fontsize{40}{45}\selectfont
]{section}

\begin{document}
\linenumbers % show line numbers
\chapter{Test}
\section{SECTION}
\lipsum[1-50]
\end{document}

相关内容