Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am a novice in LaTeX and I have one question.

Can someone tell me what if you want more heading's in LaTeX. Like 5 or 10 or even 15. Is there a package for that?

share|improve this question
2  
Could you explain 'more headings'? If you mean more nested levels, there are good reasons why as standard only \chapter, \section, \subsection and \subsubsection are numbered. –  Joseph Wright Oct 9 '11 at 8:52
    
You mean \section{A section title}? You can add as many of those as you want, no need for a package. If not, can you clarify what you're after. –  Torbjørn T. Oct 9 '11 at 8:53
    
Sometimes I need only 3 headings, but sometimes I need more like 4 to 10 or more. All headings should be in the table of contents automatically and have their parent and children Heading 1 Heading 1.1 Heading 1.2 Heading 1.2.1 Heading 1.2.2 Heading 1.2.2.1 Heading 1.2.2.2 Heading 1.2.2.1 and they all have to show in TOC: Heading 1..................1 Heading 1.1................1 Heading 1.2................2 Heading 1.2.1..............2 Heading 1.2.2..............3 Heading 1.2.2.1............3 Heading 1.2.2.2............4 Heading 1.2.2.1...........10 –  B. T. Oct 13 '11 at 15:44
1  
@B.T.: Please do not ignore the remarks about style lightly. While MS Word will allow you to commit any kind of stylistic crime, having your headings nested so deeply is a sign for an underlying problem. Your document will not be easy to read, or find anything in. Unless you are looking at the type of write-only documentation sadly popular in the IT industry these days... I have written a RPG rulebook 250 pages long, and had no need whatsoever to go beyond "subsubsection". The Intel Architecture Software Manual doesn't go beyond that, at that's a behemoth. –  DevSolar Oct 14 '11 at 9:12

3 Answers 3

This shouldn't be taken too seriously, as deep numbering is not recommended. However, here's how one can have 100 sectional levels (all are modeled after \subsubsection after that level).

\documentclass[a4paper]{report}

\makeatletter
\newcommand\level[1]{%
  \ifcase#1\relax\expandafter\chapter\or
    \expandafter\section\or
    \expandafter\subsection\or
    \expandafter\subsubsection\else
    \def\next{\@level{#1}}\expandafter\next
  \fi}
\newcommand{\@level}[1]{%
  \@startsection{level#1}
    {#1}
    {\z@}%
    {-3.25ex\@plus -1ex \@minus -.2ex}%
    {1.5ex \@plus .2ex}%
    {\normalfont\normalsize\bfseries}}

\newcounter{level4}[subsubsection]
\@namedef{thelevel4}{\thesubsubsection.\arabic{level4}}
\@namedef{level4mark}#1{}
\count@=4
\loop\ifnum\count@<100
  \begingroup\edef\x{\endgroup
    \noexpand\newcounter{level\number\numexpr\count@+1\relax}[level\number\count@]
    \noexpand\@namedef{thelevel\number\numexpr\count@+1\relax}{%
      \noexpand\@nameuse{thelevel\number\count@}.\noexpand\arabic{level\number\numexpr\count@+1\relax}}
    \noexpand\@namedef{level\number\numexpr\count@+1\relax mark}####1{}}
  \x
  \advance\count@\@ne
\repeat
\makeatother
\setcounter{secnumdepth}{100}

\begin{document}

\level{0}{abc}
\level{1}{abc}
\level{2}{abc}
\level{3}{abc}
\level{4}{abc}
\level{5}{abc}
\level{6}{abc}
\level{7}{abc}
\level{8}{abc}
\level{9}{abc}
\level{10}{abc}
\level{11}{abc}
\level{12}{abc}
\end{document}

The commands \level{0}, \level{1}, \level{2}, and \level{3} are synonymous with \chapter, \section, \subsection, and \subsubsection.

enter image description here

ADDED

In case you want also to arrange for the table of contents, here's a way.

\documentclass[a4paper]{report}

\makeatletter
\newcommand\level[1]{%
  \ifcase#1\relax\expandafter\chapter\or
    \expandafter\section\or
    \expandafter\subsection\or
    \expandafter\subsubsection\else
    \def\next{\@level{#1}}\expandafter\next
  \fi}
\newcommand{\@level}[1]{%
  \@startsection{level#1}
    {#1}
    {\z@}%
    {-3.25ex\@plus -1ex \@minus -.2ex}%
    {1.5ex \@plus .2ex}%
    {\normalfont\normalsize\bfseries}}

\newdimen\@leveldim
\newdimen\@dotsdim
{\normalfont\normalsize
 \sbox\z@{0}\global\@leveldim=\wd\z@
 \sbox\z@{.}\global\@dotsdim=\wd\z@
}

\newcounter{level4}[subsubsection]
\@namedef{thelevel4}{\thesubsubsection.\arabic{level4}}
\@namedef{level4mark}#1{}
\def\l@section{\@dottedtocline{1}{0pt}{\dimexpr\@leveldim*4+\@dotsdim*1+6pt\relax}}
\def\l@subsection{\@dottedtocline{2}{0pt}{\dimexpr\@leveldim*5+\@dotsdim*2+6pt\relax}}
\def\l@subsubsection{\@dottedtocline{3}{0pt}{\dimexpr\@leveldim*6+\@dotsdim*3+6pt\relax}}
\@namedef{l@level4}{\@dottedtocline{4}{0pt}{\dimexpr\@leveldim*7+\@dotsdim*4+6pt\relax}}

\count@=4
\def\@ncp#1{\number\numexpr\count@+#1\relax}
\loop\ifnum\count@<100
  \begingroup\edef\x{\endgroup
    \noexpand\newcounter{level\@ncp{1}}[level\number\count@]
    \noexpand\@namedef{thelevel\@ncp{1}}{%
      \noexpand\@nameuse{thelevel\@ncp{0}}.\noexpand\arabic{level\@ncp{1}}}
    \noexpand\@namedef{level\@ncp{1}mark}####1{}%
    \noexpand\@namedef{l@level\@ncp{1}}%
      {\noexpand\@dottedtocline{\@ncp{1}}{0pt}{\the\dimexpr\@leveldim*\@ncp{5}+\@dotsdim*\@ncp{0}\relax}}}%
  \x
  \advance\count@\@ne
\repeat
\makeatother
\setcounter{secnumdepth}{100}
\setcounter{tocdepth}{100}
\begin{document}
\tableofcontents

\level{0}{abc}\thispagestyle{empty}
\level{1}{abc}
\level{2}{abc}
\level{3}{abc}
\level{4}{abc}
\level{5}{abc}
\level{6}{abc}
\level{7}{abc}
\level{8}{abc}
\level{9}{abc}
\level{10}{abc}
\level{11}{abc}
\level{12}{abc}
\end{document}

However I can't stand looking at the result.

share|improve this answer
    
Nice that's what i want :) –  B. T. Oct 13 '11 at 15:32
    
Are those heading included in table of content also? –  B. T. Oct 13 '11 at 15:51
    
Also headings with \level{3} or more (4,5,6) is written on top of each other in \tableofcontents :( Help please :) –  B. T. Oct 13 '11 at 17:02
5  
@B.T. It's hard to understand the need of 10 numbered levels and harder to think about including them in the table of contents. –  egreg Oct 13 '11 at 20:13
    
I was writing some technical documentation in MS Word, and there are 10 levels of headings. I'm trying to "convert" some documents to Latex and i need more than 3- levels. And TOC is also a MUST :( –  B. T. Oct 13 '11 at 20:44

If you are a novice to LaTeX with demands for complex sectioning, you might want to take a look at ConTeXt. Unless you are using MikTeX or an old TeX Live, it should work out of the box, just run context yourfile.tex or texexec yourfile.tex on the example below:

\setupcolors[state=start]
\usemodule[subsub]
\setuphead[section][color=red,style=\bfc]
\setuphead[subsection][color=blue,style=\bfb]
\setuphead[subsubsection][style=\bfa]
\setuphead[subsubsubsection][style=bold]
\starttext
\section{first section}
\subsection{a}
\subsubsection{b}
\subsubsubsection{c}
\subsubsubsubsection{d}
\subsubsubsubsubsection{e}
\subsubsubsubsubsubsection{f}
\subsubsubsubsubsubsubsection{g}
\subsubsubsubsubsubsubsubsection{h}
\subsubsubsubsubsubsubsubsubsection{i}
\stoptext

The \usemodule[subsub] defines some additional levels, but you can just as well easily define and configure your own (there is a slight difference between pdfTeX and LuaTeX-based ConTeXt as far as sectioning is concerned, so I didn't provide any more specific example, but I can provide more details if needed). If you want to provide headings different from \section, you can use

\definehead[myniceheading][section]
\setuphead[myniceheading][color=darkgreen,style=\bib,alternative=middle,number=no]

\myniceheading{Some heading}

See ConTeXt documentation at Pragma ADE and reference for \setuphead.

share|improve this answer
    
Very nice, thank you for your answer. –  B. T. Oct 13 '11 at 15:32

I found a possible solution - for anyone having the same trouble as I:

http://www-mobile.ecs.soton.ac.uk/scripts/viewvc.cgi/yja02r/thesis/packages/subsections.sty?view=co

http://web.archive.org/web/20100303003122/http://www-mobile.ecs.soton.ac.uk/scripts/viewvc.cgi/yja02r/thesis/packages/subsections.sty?revision=1.1.1.1

new .sty file with possible unlimited number of headings

I will try to look at it later.

p.s. I hope it works :)

share|improve this answer
    
For everyone interested, it works :) –  B. T. Oct 15 '11 at 11:55
1  
I get server error when I try to access it. –  Nasser Jun 12 '13 at 9:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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