Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
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
add comment

2 Answers

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).

    For a reference, see Where can I find help files or documentation for commands like \@startsection for LaTeX?

  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:

enter image description here

\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}
share|improve this answer
add comment

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:

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.