# KOMA-Script scrreprt: Section numbering and heading embodied into the first line of text

Using KOMA-Script package scrreprt I need to have the section numbering and heading included in the first paragraph of the section itself and the numbering of sections restarting from each chapter, i.e.: instead of

Chapter 1

Rome

1.1 The Magic Of Rome

Ibam forte via sacra.............

1.2 Modern Rome

Andavo per caso per la via sacra .......

Chapter 2

Milan

2.1 Is Milan magic?

Ibam forte via sacra.............

2.2 Modern Milan

Andavo per caso per la via sacra .......

===========:========== I would like to have:

Chapter 1

Rome

1.The magic of Rome. Ibam forte via sacra.............

2.Modern Rome. Andavo per caso per la via sacra .......

Chapter 2

Milan

1.Is Milan magic. Ibam forte via sacra.............

2.Modern Milan. Andavo per caso per la via sacra .......

How can I obtain this result?

-
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Marco Daniel Apr 12 '13 at 12:14
If you use such a numbering scheme you can't work with hyperlinks. The number of the sections is always equal. –  Marco Daniel Apr 12 '13 at 12:15
Welcome to TeX.sx! It's not necessary to sign your questions (as there is already a box with your username below it). Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. –  Kurt Apr 12 '13 at 12:33

Three things are important to obtain this result:

1. Remove the chapter numbering component from that of the section numbering:

\renewcommand*\thesection{\arabic{section}}

2. Update the \section command to allow text to follow in-line with the title (a so-called run-in header). This depends on the fifth argument (or afterskip) to \@startsection. This value has to be negative. The default definition for \section is:

\newcommand\section{\@startsection{section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
\setlength{\parfillskip}{\z@ plus 1fil}\fi
\raggedsection\normalfont\sectfont\nobreak\size@section}%
}


where afterskip is given as 2.3ex \@plus.2ex (positive). We update this to now be

\renewcommand\section{\@startsection{section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{-2.3ex \@plus-.2ex}%{2.3ex \@plus.2ex}%
{\ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
\setlength{\parfillskip}{\z@ plus 1fil}\fi
\raggedsection\normalfont\sectfont\nobreak\size@section}%
}


where afterskip is now -2.3ex \@plus-.2ex (negative).

3. Force a period . after sectioning levels using

\renewcommand*{\othersectionlevelsformat}[3]{#3.\enskip}


The above also adds an \enskip, which you could remove if needed.

Here's a complete MWE containing the above modifications:

\documentclass[chapterprefix=true]{scrreprt}
\renewcommand*\thesection{\arabic{section}}
\makeatletter
\renewcommand\section{\@startsection{section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{-2.3ex \@plus-.2ex}%{2.3ex \@plus.2ex}%
{\ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
\setlength{\parfillskip}{\z@ plus 1fil}\fi
\raggedsection\normalfont\sectfont\nobreak\size@section}%
}
\makeatother
\renewcommand*{\othersectionlevelsformat}[3]{#3.\enskip}
\begin{document}
\chapter{Rome}
\section{Magic of Rome}
Ibam forte via sacra \ldots
\section{Modern Rome}
Andavo per caso per la via sacra \ldots
\chapter{Milan}
\section{Is Milan magic?}
Ibam forte via sacra \ldots
\section{Modern Milan}
Andavo per caso per la via sacra \ldots
\end{document}

-

You must redefine the counter \thesection

\documentclass[chapterprefix=true]{scrreprt}
\renewcommand*\thesection{\arabic{section}}
\begin{document}
\chapter{Rome}
\section{Magic of Rome}
Ibam forte via sacra \ldots
\section{Modern Rome}
Andavo per caso per la via sacra \ldots
\chapter{Milan}
\section{Is Milan magic?}
Ibam forte via sacra \ldots
\section{Modern Milan}
Andavo per caso per la via sacra \ldots
\end{document}


here the result:

-