Sign up ×
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 have a document which requires many levels of sectioning. I have sections, subsections and subsubsections, but require one more level below that. I can't change the sections to be parts and move everything up a level, as this document will eventually be included in another document which has parts/chapters already.

I see that the \paragraph command is used for defining the section level below subsubsection, but that doesn't produce headings in the same way that subsection and subsubsection do. Is there any way to either (1) change the \paragraph command so that it works like subsubsection but just adds another number - ie. 1.2.3.4 or (2) create a \subsubsubsection command to do the same thing?

share|improve this question
    
    
There seems to be a problem with the first answer below (see comment on that answer) - it doesn't quite work. Does anyone have any ideas? I really need to sort the numbering for my report out soon before it goes to my supervisor! – robintw Jul 3 '12 at 17:29
    
What kind of document requires this many levels of headings? – mrf Jul 3 '12 at 20:48
    
@mrf One example: Documents a person writes for themselves to keep track of what they've learned. My thesis (master's) adviser teaches so much so much so fast - or I'm that slow - that I forget it quickly. The best way for me to retain what he taught is to type it up - which is how he advised me to work with him when we started. To quickly locate parts of the document, my subsubsections have subsections and subsubsections. Then I use package hyperref to create an index so I can find them quickly. But note that I type really fast (and can learn LaTeX somewhat fast). – Jeff Aug 16 '13 at 17:00
1  
This seems like something quite a few people are into; is there any plan to develop a command which copies the style of a section level to a different level. \newsectionstyle[\subsubsection][4]{\subsubsubsection} \renewsectionstyle[\subsubsection]{\paragraph} or something along those lines. I understand that more powerful commands exist, but this specific feature seems to have gotten a large number of views and may be something to which a very basic user would like easy access. – kando Jul 17 at 14:24

2 Answers 2

up vote 72 down vote accepted

You can use the titlesec package to change the way \paragraph formats the titles and set the secnumdepth counter to four to obtain numbering for the paragraphs:

\documentclass{article}
\usepackage{titlesec}

\setcounter{secnumdepth}{4}

\titleformat{\paragraph}
{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\begin{document}

\section{Test Section}
test
\subsection{Test Subsection}
test
\subsubsection{Test Subsubsection}
test
\paragraph{Test Modified Paragraph}
test

\end{document}

enter image description here

If you want to define a new sectioning command, you can take a look at Defining custom sectioning commands.

If you want to define a fresh new sectional unit below \subsubsection, but above \paragraph, then you will have to do considerably more work: a new counter has to be created and its representation has to be appropriately defined; the sectional units \paragraph and \subparagraph will also have to be redefined, as well as they corresponding \l@... commands (controlling how the will be typeset in the ToC if the tocdepth value is increased); also, the toclevel (for eventual bookmarks) will have to be considered.

Here's an example showing how to obtain this new sectional unit giving you now the option to use \part, \section, \subsection, \subsubsection, \subsubsubsection, \paragraph, and \subparagraph:

\documentclass{article}
\usepackage{titlesec}
\usepackage{hyperref}

\titleclass{\subsubsubsection}{straight}[\subsection]

\newcounter{subsubsubsection}[subsubsection]
\renewcommand\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}
\renewcommand\theparagraph{\thesubsubsubsection.\arabic{paragraph}} % optional; useful if paragraphs are to be numbered

\titleformat{\subsubsubsection}
  {\normalfont\normalsize\bfseries}{\thesubsubsubsection}{1em}{}
\titlespacing*{\subsubsubsection}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
  {3.25ex \@plus1ex \@minus.2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\renewcommand\subparagraph{\@startsection{subparagraph}{6}{\parindent}%
  {3.25ex \@plus1ex \@minus .2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\def\toclevel@subsubsubsection{4}
\def\toclevel@paragraph{5}
\def\toclevel@paragraph{6}
\def\l@subsubsubsection{\@dottedtocline{4}{7em}{4em}}
\def\l@paragraph{\@dottedtocline{5}{10em}{5em}}
\def\l@subparagraph{\@dottedtocline{6}{14em}{6em}}
\makeatother

\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}

\begin{document}

\tableofcontents
\section{Test Section}
test
\subsection{Test Subsection}
test
\subsubsection{Test Subsubsection}
test
\subsubsubsection{Test Subsubsubsection}
test
\paragraph{Test Paragraph}
test
\subparagraph{Test Subparagraph}
test

\end{document}

enter image description here

share|improve this answer
    
Thanks for this, I've been using it and have only just realised that the section numbering for \subsubsubsection doesn't seem to restart after every \subsubsection. That is, I get 1.1.1, 1.1.1.1, 1.1.1.2, 1.1.2, 1.1.2.3 - where the last one should be 1.1.2.1. Do you have any ideas how to fix this? – robintw Jul 2 '12 at 15:52
6  
@robintw You have to say \newcounter{subsubsubsection}[subsubsection] so that the new counter is bound to the subsubsection counter. – egreg Jul 3 '12 at 17:34
    
I applied the first solution (with \paragraph) - it works great, only in the ToC, it looks like this - do you know how to make the alignment match? – Emanuel Berg Dec 31 '12 at 0:32
1  
@Frankenstein Change the \def\l@subsubsubsection{...} lines to \def\l@subsubsubsection{\@dottedtocline{4}{9em}{4em}} \def\l@paragraph{\@dottedtocline{5}{12em}{5em}} \def\l@subparagraph{\@dottedtocline{6}{15em}{6em}} choose the second and third arguments appropriately. – Gonzalo Medina Sep 12 at 1:52
1  
@Frankenstein \l@<name> is the command in charge of typesetting entries of type <name> in a list such as the ToC, the LoF, the LoT. \@dottedtocline is a kernel command producing the actual entry format (number, title/caption, leading dots, page number). First argument: level for <name>; second argument indentation from the left margin; third argument: space reserved for the number. – Gonzalo Medina Sep 12 at 2:32

Here's a solution that doesn't require the use of a specialized package such as titlesec or sectsty. (There's nothing wrong per se, obviously, with using packages to achieve a certain goal; nevertheless, I think it can be instructive at times to see how one can manipulate some of LaTeX's built-in commands directly.)

If you use the article document class, the default appearance of the output of the commands \subsubsection and \paragraph is set up as follows:

\newcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                {-3.25ex\@plus -1ex \@minus -.2ex}%
                {1.5ex \@plus .2ex}%
                {\normalfont\normalsize\bfseries}}
\newcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                {3.25ex \@plus1ex \@minus.2ex}%
                {-1em}%
                {\normalfont\normalsize\bfseries}}

To make the \paragraph command behave more like the \subsubsection command, but with less vertical spacing above and below the sectioning header line(s), you could modify the \paragraph command to make its output behave as if it were a "subsubsubsection". The following MWE illustrates a possible setup.

\documentclass{article}
\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
            {-2.5ex\@plus -1ex \@minus -.25ex}%
            {1.25ex \@plus .25ex}%
            {\normalfont\normalsize\bfseries}}
\makeatother
\setcounter{secnumdepth}{4} % how many sectioning levels to assign numbers to
\setcounter{tocdepth}{4}    % how many sectioning levels to show in ToC

\begin{document}
\tableofcontents
\section{A}
\subsection{B}
\subsubsection{C1}
\paragraph{D1}
\paragraph{D2}
\subsubsection{C2}
\end{document}

enter image description here

share|improve this answer

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.
http://tex.stackexchange.com/questions/60209/how-to-add-an-extra-level-of-sections-with-headings-below-subsubsection
tex.stackexchange.com
crawl=CC-MAIN-2015-48
94917
application/http; msgtype=response
sha1:SSHJ6W2WMVNNV2UCWUCLBTGTXMMHRFGN
<urn:uuid:2cdd3919-93e4-45c4-af1d-c887b50b5970>
2015-11-29T05:28:01Z
104.16.115.182
sha1:JNZPA2HGHDJ73SJCZ4DWMLOSN6NB76AN
<urn:uuid:71bd5a40-2905-44af-986c-b84e147663ad>
http://tex.stackexchange.com/questions/60209/how-to-add-an-extra-level-of-sections-with-headings-below-subsubsection
response
<urn:uuid:7f83047e-c2a2-43a8-8745-3d3a37364fcf>
robots: classic
hostname: ip-10-71-132-137.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2015-48
operator: CommonCrawl Admin
description: Wide crawl of the web for Nov 2015
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf