3

I have to build a document structure with the different sectioning-levels (and therefor also the table of contents) having a certain, custom "numbering" instead of the default mathematical. E.g. a section should alsways be starting like with roman numbering (what you do with "\Alph*.") in the list-environment, a subsection always "(\arabic*)", a paragraph with "\alph*\alph*)" and so on.

I've searched plenty of times for that, but either nobody was ever in need of this before me, or I'm missing the correct tags to search for.

Any way I can do that?

This is, what the toc should look like:

A. Section
 I. Subsection
 II. Subsection
  1) Subsubsection
   a) Paragraph
  2) Subsubsection
   a) Paragraph
    aa) Subparagraph
B. Section
 I. Subsection
  1) Subsubsection
4
  • Well there is no real way I tried it because I've got no clue how to do it at all. I'll add an concrete example, how it shall look like in the toc...
    – user43961
    Jan 30, 2014 at 8:47
  • You can take a look at the titletoc (included in titlesec) or the tocloft package.
    – Bernard
    Jan 30, 2014 at 9:32
  • 3
    Do you want this behavior only in the ToC or throughout the document, as well? Jan 30, 2014 at 9:50
  • document as well
    – user43961
    Jan 30, 2014 at 18:00

1 Answer 1

6

To obtain this behavior throughout the document, we use the titlesec package:

\usepackage{titlesec}

\renewcommand{\thesection}{\Alph{section}}
\titleformat{\section}{\normalfont\Large\bfseries}{\thesection.}{1em}{}
\renewcommand{\thesubsection}{\Roman{subsection}}
\titleformat{\subsection}{\normalfont\large\bfseries}{\thesubsection.}{1em}{}
\renewcommand{\thesubsubsection}{\arabic{subsubsection}}
\titleformat{\subsubsection}{\normalfont\normalsize\bfseries}{\thesubsubsection)}{1em}{}
\renewcommand{\theparagraph}{\alph{paragraph}}
\titleformat{\paragraph}[runin]{\normalfont\normalsize\bfseries}{\theparagraph)}{1em}{}
\renewcommand{\thesubparagraph}{\alph{subparagraph}\alph{subparagraph}}
\titleformat{\subparagraph}[runin]{\normalfont\normalsize\bfseries}{\thesubparagraph)}{1em}{}

In regards of the ToC, we use the tocloft package for the customization:

\usepackage{tocloft}

\renewcommand{\cftsecaftersnum}{.}
\renewcommand{\cftsubsecaftersnum}{.}
\renewcommand{\cftsubsubsecaftersnum}{)}
\renewcommand{\cftparaaftersnum}{)}
\renewcommand{\cftsubparaaftersnum}{)}

\setlength{\cftsecnumwidth}{1.8em}
\setlength{\cftsubsecnumwidth}{2.3em}
\setlength{\cftsubsubsecnumwidth}{1.8em}
\setlength{\cftparanumwidth}{1.8em}
\setlength{\cftsubparanumwidth}{2.2em}

\setlength{\cftsecindent}{0em}
\setlength{\cftsubsecindent}{1.8em}
\setlength{\cftsubsubsecindent}{4.1em}
\setlength{\cftparaindent}{5.9em}
\setlength{\cftsubparaindent}{7.7em}

So, this MWE

\documentclass{article}

\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

\usepackage{titlesec}

\renewcommand{\thesection}{\Alph{section}}
\titleformat{\section}{\normalfont\Large\bfseries}{\thesection.}{1em}{}
\renewcommand{\thesubsection}{\Roman{subsection}}
\titleformat{\subsection}{\normalfont\large\bfseries}{\thesubsection.}{1em}{}
\renewcommand{\thesubsubsection}{\arabic{subsubsection}}
\titleformat{\subsubsection}{\normalfont\normalsize\bfseries}{\thesubsubsection)}{1em}{}
\renewcommand{\theparagraph}{\alph{paragraph}}
\titleformat{\paragraph}[runin]{\normalfont\normalsize\bfseries}{\theparagraph)}{1em}{}
\renewcommand{\thesubparagraph}{\alph{subparagraph}\alph{subparagraph}}
\titleformat{\subparagraph}[runin]{\normalfont\normalsize\bfseries}{\thesubparagraph)}{1em}{}

\usepackage{tocloft}

\renewcommand{\cftsecaftersnum}{.}
\renewcommand{\cftsubsecaftersnum}{.}
\renewcommand{\cftsubsubsecaftersnum}{)}
\renewcommand{\cftparaaftersnum}{)}
\renewcommand{\cftsubparaaftersnum}{)}

\setlength{\cftsecnumwidth}{1.8em}
\setlength{\cftsubsecnumwidth}{2.3em}
\setlength{\cftsubsubsecnumwidth}{1.8em}
\setlength{\cftparanumwidth}{1.8em}
\setlength{\cftsubparanumwidth}{2.2em}

\setlength{\cftsecindent}{0em}
\setlength{\cftsubsecindent}{1.8em}
\setlength{\cftsubsubsecindent}{4.1em}
\setlength{\cftparaindent}{5.9em}
\setlength{\cftsubparaindent}{7.7em}

\begin{document}

\tableofcontents

\bigskip\bigskip

\section{A section}

\subsection{A subsection}

\subsection{A subsection}

\subsubsection{A subsubsection}

\paragraph{A paragraph}

\subsubsection{A subsubsection}

\paragraph{A paragraph}

\subparagraph{A subparagraph}

\section{A section}

\subsection{A subsection}

\subsubsection{A subsubsection}

\end{document} 

yields this result

enter image description here

1
  • wow, that was amazing... I thought it must be possible with a little less effort... but it works perfectly!
    – user43961
    Jan 30, 2014 at 18:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .