GeneralKOMA-Script | Dot after ((Sub-)sub-)Section Heading

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
moggy
Posts: 2
Joined: Wed May 23, 2012 4:48 pm

KOMA-Script | Dot after ((Sub-)sub-)Section Heading

Post by moggy »

Hi everyone!

How can I add a dot after the section and chapter headings? It's supposed to look like something like this:
1.2. Introduction.
I understand that this can be achieved by using the titlesec package (see bottom of this post), but as far as I know, KOMA isn't really compatible with titlesec and I would imagine that there is some way to do this in KOMA, without using another package, but I couldn't find out how until now.

Any ideas?

Cheers,
moggy

Code: Select all

\documentclass{scrbook}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}

% macht, das die Kapitelnumber nicht in Nummerierung der Sections (und darunter) auftaucht
\renewcommand*\thesection{\arabic{section}}

% macht, dass noch ein  Punkt hinter Nummern aller (sub)sections kommt
\makeatletter
\renewcommand\@seccntformat[1]{\csname the#1\endcsname.\quad}
\makeatother

%formatting section headings
\makeatletter
\renewcommand{\section}{\@startsection
{section}%                   % the name
{1}%                         % the level
{0mm}%                       % the indent
{\baselineskip}%            % the before skip
{-\baselineskip}%          % the after skip
{\bfseries\textsc}} % the style
\makeatother

\makeatletter
\renewcommand{\subsection}{\@startsection
{subsection}%                   % the name
{2}%                         % the level
{0mm}%                       % the indent
{\baselineskip}%            % the before skip
{-\baselineskip}%          % the after skip
{\bfseries\textsc}} % the style
\makeatother

\makeatletter
\renewcommand{\subsubsection}{\@startsection
{subsubsection}%                   % the name
{3}%                         % the level
{0mm}%                       % the indent
{\baselineskip}%            % the before skip
{-\baselineskip}%          % the after skip
{\bfseries\textsc}} % the style
\makeatother

\begin{document}

\section{First Section}

some text

\subsection{First Subsection}

some more text

\subsubsection{First Subsubsection}

even more text

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

KOMA-Script | Dot after ((Sub-)sub-)Section Heading

Post by Stefan Kottwitz »

Hi moggy,

welcome to the board!

This redefinition adds the dot for standard classes and KOMA-Script classes as well. It works also with optional arguments for the sectioning commands. At first, we save the original \@sect command, then we redefine it and call the saved one, with the same parameters plus the dot.

Code: Select all

\makeatletter
\let\std@sect\@sect
\def\@sect#1#2#3#4#5#6[#7]#8{\std@sect{#1}{#2}{#3}{#4}{#5}{#6}[#7.]{#8.}}
\makeatother
Stefan
LaTeX.org admin
moggy
Posts: 2
Joined: Wed May 23, 2012 4:48 pm

Re: KOMA-Script | Dot after ((Sub-)sub-)Section Heading

Post by moggy »

Dankeschön! This really helped me a lot!!

Unfortunately I don't understand what exactly the code does, so if you have a minute, could you explain? I'm guessing, #7 is the short title and #8 is the title?
pingu
Posts: 3
Joined: Fri Aug 22, 2014 7:44 pm

Re: KOMA-Script | Dot after ((Sub-)sub-)Section Heading

Post by pingu »

Hello Stefan,

Could you give a hint on how to adapt this to subsubsection's only ?

That is, a dot should be inserted after the title of a subsubsection, but not on higher levels such as a section or subsection.
Post Reply