Tuesday, May 12, 2009

LaTeX \subsubsubsection

This small article will present my workaround for the problem of defining a "\subsubsubsection" command in LaTeX, so that the properties of the formatting, environment and also the generation of the table of contents stays the same as in the case of "\subsection", but also the new level of hierarchy is added to the document.

I have tried to follow some of the proposed solutions on the internet, but I failed to achieve the result, some of them are here, here.

For example:

1. Section

1.1 Subsection

1.1.1 Subsubsection

1.1.1.1 Subsubsubsection


I consider it a "hack", as amazingly for me, the combination below delivered the desired result.

The snippet of the code follows:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%to be inserted in the main file %
%the \mypar command makes the 3-folded subsectioning :) %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\mypar}{\subsubparagraph}

\makeatletter

\renewcommand\mypar{\@startsection{paragraph}{4}{0ex}{-3.25ex plus -1ex minus -0.2ex}{1.5ex plus 0.2ex}{\normalfont\normalsize\bfseries}}
\makeatother
\stepcounter{secnumdepth}
\stepcounter{tocdepth}

\renewcommand{\paragraph}{\subparagraph}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Notice the triple use of the \renewcommand.

In the first line I create a new command \mypar which makes it act as a \subsubparagraph. Later on the \renewcommand applied to it redefines the environment properties and also sets the table of contents generation parameters, based on the \paragraph environment settings.

At the very last line, the surprising \renewcommand applied to \paragraph makes the previous lines work as desired.

Comments concerning the explanation of these facts are welcome, as I had not yet the chance to dive deeper into the underlying sty, and source files of the LaTeX packages, nor am an expert in style programming.

Nevertheless, I consider it useful for someone like me in the need of this functionality to have this hack in the hands :)

1 comment:

Charan Char said...

Thanks for this post Vitalie.
Its very useful for me.