0

In the book I translate, some sections are optional and this is denoted by a star before section number .... for example, Section 3.5 with the Title A is not optional but Section 3.6 with the Title B is optional .. this gives the results

3.5 Title A and
*3.6 Title B

How can put a star before section number and how i can remove from the next (not optional) sections?

  • 1
    You should take a look at the documentation of titlesec, §4.3 Variants. – Bernard Mar 19 '18 at 14:21
1

As @Bernard commented this is possible with the titlesec package. However, it is also easy to do without packages, which might be preferred if you don't want to use titlesec for some reason.

MWE:

\documentclass{book}
\newcommand{\optionalsection}[1]{%
\renewcommand\thesection{*\arabic{chapter}.\arabic{section}}%
\section{#1}%
\renewcommand\thesection{\arabic{chapter}.\arabic{section}}%
}
\begin{document}
\chapter{First chapter}
\section{First section}
\optionalsection{Optional section}
\section{Third section}
\end{document}

Here a new command called \optionalsection is defined that first changes the section number format to a *, the chapter number, a dot, and the section number, then creates a section with this format, then resets the section number to the default format.

Result:

enter image description here

  • 2
    Perhaps it would look nicer to code \renewcommand\thesection{\llap{*}\arabic{chapter}.\arabic{section}}%: the chapter number would till be at the left margin, and the star would be protruding into the left margin. – Bernard Mar 19 '18 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.