Search code examples
latexoverleaf

Spacing between label and sectiontitle


I would like to change the spacing between the label and the section title. Right now I'm using titlesec with scrartcl, but there are warnings. I guess it is because titlesec has some problems with KOMA-script.

So I would like to create the same by using KOMA-Script commands. Do you have an idea?

\documentclass[pdftex,a4paper]{scrartcl}
\usepackage{titlesec}

\titleformat{\section}[hang]
{\normalfont\bfseries}{\thesection}{1cm}{}


\titleformat{\subsection}[hang]
{\normalfont\bfseries}{\thesubsection}{3cm}{}

\titleformat{\subsubsection}[hang]
{\normalfont\bfseries}{\thesubsubsection}{5cm}{}

\begin{document}

\section{Ein erster Abschnitt}
\subsection{Unterabschnitt}
\subsubsection{Unter-Unterabschnitt}

\end{document}

Warnings

Output document


Solution

  • Quick hack:

    \documentclass[
    %pdftex,
    a4paper]{scrartcl}
    
    \renewcommand*{\sectionformat}{\thesection\autodot\enskip\hspace{2cm}}
    \renewcommand*{\subsectionformat}{\thesubsection\autodot\enskip\hspace{2cm}} 
    \renewcommand*{\subsubsectionformat}{\thesubsubsection\autodot\enskip\hspace{2cm}}
    
    \begin{document}
    
    \section{Ein erster Abschnitt}
    \subsection{Unterabschnitt}
    \subsubsection{Unter-Unterabschnitt}
    
    \end{document}