1

I would be grateful for any advice please. I would like to format section headings with the Mathilde font. However, I receive an the error:

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`

Apart from the error, I notice that the font in the section is not changed to Mathilde.

I attach a MWE that illustrates the problem.

\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}
4
  • 6
    Both KOMA and titlesec do sophisticated setups to the sectioning commands. Don't use both. Use one of them!
    – user31729
    Commented Dec 22, 2015 at 23:49
  • 4
    And if you are using KOMA, use KOMA! At least, you'll lose functionality otherwise. Also, don't do \fontspec{} repeatedly (in every section heading, effectively). Create a new family and then use that.
    – cfr
    Commented Dec 23, 2015 at 0:06
  • 1
    By the way, you didn't check your code compiled before posting it, did you?
    – cfr
    Commented Dec 23, 2015 at 0:07
  • Very many thanks. Apologies for not checking the code before posting! cfr what do you mean "create a new family...?"
    – Mike
    Commented Dec 23, 2015 at 0:46

1 Answer 1

2

You get warnings if you use titlesec together with a KOMA-Script class. But the error message

File ended while scanning use of \scr@ttl@@extract.

is caused by the combination of titlesec and grid with a KOMA-Script class. Note that grid redefines the commands \section, \subsection and \subsubsection too. From the 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}}

This is also the reason why the font of your section title can not be changed by \addtokomafont or \setkomafont. You have to use

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

after loading grid. But then the KOMA-Script definition of the section title "wins".

I do not know why you are loading grid. But here is a suggestion without 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}

enter image description here


If you really want to use package titlesec (this is not recommended) load it before 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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .