# French bis/ter/quater/quinquies section numbering with manual line breaks

As a follow-up to my previous Question French section numbering using bis, ter, etc, I'm attempting to manually add line breaks in my section titles that show up in the body of the text as intended but do not break manually in the Table of Contents. I hope this is clear - if not, the screencap below should hopefully show what I'm after:

This I achieved using manual section numbering, which is what I sought to avoid in the first Question. The syntax for that is as follows:

\documentclass{book}
\usepackage{xparse}
\usepackage{enumitem}
\usepackage{titlesec}
\usepackage{lipsum}
\usepackage{titletoc}

\titleformat{\section}[block]{\normalfont\normalsize\itshape\filcenter}{\thesection. ---}{0.5em}{}
\renewcommand\thesection{\arabic{section}}

\begin{document}
\tableofcontents

\lipsum[1]
\section*{1 \textit{bis}. --- Second section header is very long \\ and I want to control the location where it breaks}\addcontentsline{toc}{section}{1 \textit{bis}    Second section header is very long and I want to control the location where it breaks}
\lipsum[4]

\end{document}


Here's my non-working MWE, based on the syntax mvienney came up with in the aforementioned Question. Note that I did not use this syntax to come up with the image above. If I try to put line breaks in the section titles for this syntax, it fails to compile.

\documentclass{book}
\usepackage{xparse}
\usepackage{enumitem}
\usepackage[explicit]{titlesec}
\usepackage{lipsum}
\usepackage{titletoc}

\ExplSyntaxOn
\seq_new:N \bislist
\seq_set_split:Nnn \bislist {;} {bis;ter;quater;quinquies;sexies;septies;octies;novies;decies}
\NewDocumentCommand {\bisprint} {m}
{
\seq_item:Nn \bislist {#1}
}
\ExplSyntaxOff

\newcounter{bis}
\stepcounter{bis}
\titleformat{\section}[block]{\normalfont\normalsize\itshape\filcenter}{\thesection. --- #1}{0.5em}{}[\setcounter{bis}{1}]
\renewcommand\thesection{\arabic{section}}
\titleformat{name=\section,numberless}[block]{\normalfont\normalsize\itshape\filcenter}{\arabic{section} \textit{\bisprint{\arabic{bis}}}. --- #1}{0.5em}{}[ \addcontentsline{toc}{section}{\numberline{\arabic{section} \textit{\bisprint{\arabic{bis}}}}#1} \stepcounter{bis}]

\makeatletter
\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{3.5em}} %change the last parameter to 2.5em if you do not go further that ter and to 3.5 if you don't go further than quater
\makeatother

\begin{document}
\tableofcontents

\lipsum[1]
\section*{Second section header is very long and I want to control the location where it breaks}
\lipsum[4]

\end{document}


Here is one option: Using a special (robust) macro \bodyonlynewline as your manual line-breaking technique. This macro will only break the line inside the body text, but not the ToC.

\documentclass{book}
\usepackage{xparse}
\usepackage[explicit]{titlesec}
\usepackage{lipsum}

\ExplSyntaxOn
\seq_new:N \bislist
\seq_set_split:Nnn \bislist {;} {bis;ter;quater;quinquies;sexies;septies;octies;novies;decies}
\NewDocumentCommand {\bisprint} {m}
{
\seq_item:Nn \bislist {#1}
}
\ExplSyntaxOff

\newcounter{bis}
\stepcounter{bis}
\titleformat{\section}[block]{\normalfont\normalsize\itshape\filcenter}{\thesection. --- #1}{0.5em}{}[\setcounter{bis}{1}]
\renewcommand\thesection{\arabic{section}}
\titleformat{name=\section,numberless}[block]{\normalfont\normalsize\itshape\filcenter}{\arabic{section} \textit{\bisprint{\arabic{bis}}}. --- #1}{0.5em}{}[ \addcontentsline{toc}{section}{\protect\numberline{\arabic{section} \textit{\bisprint{\arabic{bis}}}}#1} \stepcounter{bis}]

\makeatletter
\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{3.5em}} %change the last parameter to 2.5em if you do not go further that ter and to 3.5 if you don't go further than quater
\makeatother
\DeclareRobustCommand{\bodyonlynewline}{}% Macro does nothing
\let\oldtableofcontents\tableofcontents
\renewcommand{\tableofcontents}{%
\oldtableofcontents
\DeclareRobustCommand{\bodyonlynewline}{\\}% Macro breaks line only _after_ ToC
}

\begin{document}
\tableofcontents

\lipsum[1]
\section*{Second section header is very long \bodyonlynewline and I want to control the location where it breaks}
\lipsum[4]

\end{document}


Note the use of \protect\numberline in the numberless formatting of \section. Otherwise expansion of \numberline could cause problems.

• I'm using package tocloft, which appears to conflict with this syntax. Any idea for a workaround? – grfrazee Jul 16 '15 at 13:15
• Your syntax works when I disable tocloft, but since I'll want to reformat the TOC, I'd like to keep that package in. I edited the Question to include that package in the preamble for clarity. – grfrazee Jul 16 '15 at 13:29
• @grfrazee: You're dealing with ToC-related content. Why would you not mention that you're using tocloft from the start?! Also, I think it's better to use titletoc since you're using titlesec. – Werner Jul 16 '15 at 14:35
• Apologies, I'm new to TeX and haven't figured out all the interrelationships between things yet. – grfrazee Jul 16 '15 at 14:56
• I've changed to using titletoc in lieu of tocloft per your suggestion, and am marking the Question as answered. Thanks for the help. – grfrazee Jul 16 '15 at 15:43