0

I create the fourth-level section title following this link.

With the below code snippet, the fourth level is created but I want to reduce the spacing between the section number and the section title, e.g., 1.1.1.1 D1.

\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} \end{document}

Here is the figure to illustrate my confusion:

enter image description here

I just want to reduce the space which is represented as the red rectangle.

Any help is appreciated!

tush
  • 1,115
QUIIToT
  • 25

1 Answers1

0

You need to change the last length in l@paragraph (l stands for "list"):

\documentclass{article}
\makeatletter
\renewcommand*\l@paragraph{\@dottedtocline{4}{7.0em}{3.5em}}\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} \end{document}

To clarify:

Each header has a l@ command that appears in article.cls (located in most tex ditros at texmf-dist/tex/latex/base/article.cls). The original values was 4.1em.

Just before l@paragraph you can find similar commands for section (l@section) and subsection.

enter image description here

tush
  • 1,115