6

I want to label some of my sections listed in my contents page as 'Introductory'.

I thought I could achieve this by having a dotted box around these chapters in the contents page that marks them as introductory, though I am open to other suggestions.

Have you any suggestions as to how I can edit my contents page to accommodate this?

6

Code

\documentclass{article}
\usepackage{etoolbox}

\makeatletter
\newcounter{introsection}
\newcommand*{\introsectionmark}[1]{}
\renewcommand \theintrosection {\@arabic\c@section}
\newcommand\introsection{%
\@start@introsection {section}{1}{\z@}%
                     {-3.5ex \@plus -1ex \@minus -.2ex}%
                     {2.3ex \@plus.2ex}%
                     {\normalfont\Large\bfseries}
}
\let\@start@introsection\@startsection
\patchcmd{\@start@introsection}{\@sect}{\@introsect}{}{}
\def\intronumberline#1{\hspace*{-3.5pt}\numberline{\fbox{#1}}\hspace*{2.5pt}}
\def\addintrocontentsline#1#2#3{%
  \addtocontents{#1}{\protect\contentsline{#2}{\hspace*{-3.5pt}\fbox{#3}}{\thepage}}}
\let\@introsect\@sect
\patchcmd{\@introsect}{\addcontentsline}{\addintrocontentsline}{}{}
%\patchcmd{\@introsect}{\numberline}{\intronumberline}{}{}
\def\intromatter{\let\section\introsection}
\def\mainmatter{\let\section\ltx@section}
  \let\ltx@section\section
\makeatother

\begin{document}
\tableofcontents
\introsection{One}
\introsection{Two}
\section{Three}
\section{Four}
\end{document}

Remark

This solution provides a sectioning command \introsection that can be used as usual, but adds a framebox around its toc entry. Alternatively you can have the box only around the section number by using line 21 instead of 20.

If you are using the article class you can also use the above defined macros \intromatter and \mainmatter which are meant to be used like the similar and anologous ones of the book class:

\begin{document}
\tableofcontents
\intromatter
\section{One}
\section{Two}
\mainmatter
\section{Three}
\section{Four}
\end{document}

Output

enter image description here enter image description here

Addendum

You can of course use another styling of frame by replacing \fbox with another macro that fulfills your needs.

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.