1

I'm asking the question again since I encounter the same issue using book class. Therefore, it doesn't seem to be related to a compatibility issue between titlesec and KOMA-script.

What is the problem? For each \section* or \subsection*that appears in the document, there is this error message:

              p

l.53 ...on*{Peut-on lire facilement le gaélique?}

A number should have been here; I inserted 0'. (If you can't figure out why I needed to see a number, look upweird error' in the index to The TeXbook.)

Here is the MWE I'm using.

\documentclass[12pt,openright]{book} 
\usepackage[a5paper]{geometry}
\usepackage[T1]{fontenc}                
\usepackage{lipsum}
\usepackage{palatino}
\usepackage{amsthm}
\usepackage{setspace}
\linespread{1.2}
\usepackage[dvipsnames]{xcolor}
\newcommand\gae[1]{\textcolor{NavyBlue}{\textbf{#1}}}
\usepackage{tipa}
\usepackage{gensymb}
\usepackage{parskip}
\usepackage{etoolbox}
\usepackage[many]{tcolorbox}
\AtBeginEnvironment{tcolorbox}{\small}
\usepackage[explicit]{titlesec}
\usepackage{tikz}

% CHAPTER \newlength\chapnumb \setlength\chapnumb{3cm}

\titleformat{\chapter}[block] { \normalfont\sffamily}{}{0pt} { \parbox[b]{\chapnumb}{ \fontsize{120}{110}\selectfont\thechapter} \parbox[b]{\dimexpr\textwidth-\chapnumb\relax}{ \raggedleft \hfill{{\color{blue!50!black}\LARGE#1}}\ \rule{\dimexpr\textwidth-\chapnumb\relax}{0.4pt} } } \titlespacing{\chapter}{0pt}{1}{2}

% Section \titleformat{name=\chapter,numberless}[block] {\normalfont\sffamily}{}{0pt} {\parbox[b]{\chapnumb}{% \mbox{}}% \parbox[b]{\dimexpr\textwidth-\chapnumb\relax} {% \raggedleft% \hfill{{\color{blue!10!black}\LARGE#1}}\ {\color{blue}\rule{\dimexpr\textwidth-\chapnumb\relax}{0.4pt}}}}

%%%%% SECTION \newcommand{\hsp}{\hspace{8pt}} \titleformat{name=\section, numberless} [hang] {\fontsize{14pt}{}} {} {0pt} {\tikz\node[draw=white, inner xsep=0pt,inner ysep=0.3ex,left color=gray!60!white,right color=white!90!black]{\hsp {\color{black!20!blue}\textsc{#1}} \hsp{}};}

%%%%% SUBSECTION \titleformat{name=\subsection, numberless}[block] {\fontsize{13pt}} {} {0pt} {\textsc{#1}}

\usepackage{microtype} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} \chapter{Gaelic from Scotland} \lipsum[1-3] \section{Gàidhlig} \lipsum[1-3] \subsection*{The vowel combinations} \lipsum[1-3] \tableofcontents

\end{document}

The error disappears if I use a label such as \thesection instead of an empty argument in \titleformat.

However it adds a numbering whereas I wish to have numblerless chapter, section... titles.

Any help will be greatly appreciated!

Cedric
  • 63
  • 1
    KOMA-script and titlesec seem to be incompatible, you should probably choose one or the other. – Marijn Aug 03 '21 at 13:15
  • 4
    Possible duplicate: Incompatibilities between KOMA-Script and titlesec. See specifically the last answer (https://tex.stackexchange.com/a/324141). – Marijn Aug 03 '21 at 13:15
  • It does work well with \addchap but not with \addsed. That's why I thought it may not be directly related to the use of KOMA-script. I will change the class and see whether it solves the issue. – Cedric Aug 03 '21 at 13:49
  • @Marijn As follow-up. I used the book class with the exact same code and it provides the same error message. Seems like it's rather on the titlesec side that the issue comes from. – Cedric Aug 03 '21 at 14:16
  • Ok, then the duplicate is not really applicable (although you may encounter other problems with this combination). Unfortunately the question is already closed, you can try to get it reopened by editing the question to use (only) the MWE with the book class and a sentence or two in the edited question that this does not seem to be a compatibility issue between KOMAscript and titlesec. When you make that edit the question is automatically put in a reopen queue where high-reputation users can vote to reopen the question (and then the answer box becomes available again for answers). – Marijn Aug 03 '21 at 19:47
  • @Marijn Thanks for the suggestion. – Cedric Aug 05 '21 at 11:14

1 Answers1

1

The problem is how you use the \fontsize command. \fontsize{14pt}{} is wrong in the \titleformat for section, as is \fontsize{13pt} in the \titleformat for subsection.

  • \fontsize takes two parameters. The first one is the font size, the second one is the baseline skip. If you omit the unit, pt is taken as default.

  • You have to follow the \fontsize{...}{...} command by \selectfont otherwise it doesn't take effect.

\documentclass{article} 
\usepackage{titlesec}
\titleformat{name=\section,numberless}[hang]{\fontsize{14}{16}\selectfont}{}{0pt}{}
\begin{document}
\noindent
Some text.
\section*{Header}
Some more text.
\end{document}

enter image description here

gernot
  • 49,614