Page Layout ⇒ Star before Section Heading
Star before Section Heading
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 !
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Star before Section Heading
[1] View topic: Place * (or other) at section number
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Star before Section Heading
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}
- 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. […]
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Star before Section Heading
