Dear all,
I'm writing a book, and some of the sections in my chapters are optional.
In order to make this clear to the reader I would like to add a * in front of the number of those sections (both in the text, and in the contents). For example, I want to change
6.1.1 Historical prelude
to
*6.1.1 Historical prelude
Is there an easy way to do this, without affecting ALL the sections in my chapters ?
Thank you so much in advance !
Page Layout ⇒ Star before Section Heading
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Star before Section Heading
Perhaps you can adapt a solution given in another topic [1]. In case of upcoming problems, feel free to ask further targeted questions.
[1] View topic: Place * (or other) at section number
Best regards and welcome to the board
Thorsten
[1] View topic: Place * (or other) at section number
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Star before Section Heading
Thank you a lot localghost! This already helped a lot!
I succeeded in placing a * in front of the section numbers, but still have some problems with the contents.
I am using the minitoc package to produce a mini table of contents at the start of my chapter. When I star a section, no star appears in the minitoc, but the dots connecting the title and page number disappear, and everything is shifted a little. For example:
6.1 Optional section ............................................................. 2
6.1.1 Subsection ................................................................... 4
becomes
6.1 Optional section 2
6.1.1 Subsection ................................................................... 4
I used the following texcode:
Any ideas ?
I succeeded in placing a * in front of the section numbers, but still have some problems with the contents.
I am using the minitoc package to produce a mini table of contents at the start of my chapter. When I star a section, no star appears in the minitoc, but the dots connecting the title and page number disappear, and everything is shifted a little. For example:
6.1 Optional section ............................................................. 2
6.1.1 Subsection ................................................................... 4
becomes
6.1 Optional section 2
6.1.1 Subsection ................................................................... 4
I used the following texcode:
Code: Select all
\newcommand*{\secmark}{}
\newcommand*{\marktotoc}[1]{\renewcommand{\secmark}{#1}}
\newenvironment{optional}{
\renewcommand*{\secmark}{*}
\addtocontents{toc}{\protect\marktotoc{*}}
}{\addtocontents{toc}{\protect\marktotoc{}}}
\titleformat{\section}{\Large\bfseries}{\makebox[1.78em][l]{\secmark\thesection}}{0.5em}{}
\titleformat{\subsection}{\large\bfseries}{\makebox[2.56em][l]{\secmark\thesubsection}}{0.5em}{}
\titlecontents{section}[4em]{}{\bfseries\contentslabel[\secmark\thecontentslabel]{2.5em}}{\hspace*{1.5em}}{\titlerule*{}\bfseries\contentspage}
Last edited by Stefan Kottwitz on Sun Jun 24, 2012 10:33 am, edited 1 time in total.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Star before Section Heading
Drop that package and use a similar feature of titletoc as described in Section 6.3 of its manual.Mendeleev wrote:[…] I am using the minitoc package to produce a mini table of contents at the start of my chapter. […]
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Star before Section Heading
Thanks. I'll give it a try 
