# Title between lines

So I want to have one line above and one under the title of a chapter in scrreprt, like:

_________________________________________________
1. Introduction
_________________________________________________


But with the same space between the lines and the title.

So this is what I've tried with the package titlesec:

\titleformat{\section}[display]
{}
{}
{}
{\titlerule
\vspace{0.2pc}%
\thesection\bfseries\hspace{5pt}\filright}
[\vspace{0.1pc}%
\titlerule]


But it's still not working fine, e.g. at the begining of one chapter on a new page there is a lot of space between the top margin and the chapter name and I only get the number of the chapter in a good position with \hspace{5pt}.

Between: Is there any chance to have the same code for srreprt and scrbook? (after replacing \section by \chapter etc.)

Anybody could help me?

-

In the MWE below I've used

\titleformat{\chapter}[display]
{\normalfont\Large\bfseries}
{\titlerule
\vspace{1pc}%
\LARGE\thechapter\hskip 9pt#1}
{1pc}
{\titlerule
\vspace{1pc}%
\Huge}


to give

and

\titlespacing{\chapter}{0pt}{*4}{-0.1cm}


to adjust the spacing. you can tweak this necessary :)

\documentclass{scrreprt}

\usepackage{lipsum}

% custom chapter
\titleformat{\chapter}[display]
{\normalfont\Large\bfseries}
{\titlerule
\vspace{1pc}%
\LARGE\thechapter\hskip 9pt#1}
{1pc}
{\titlerule
\vspace{1pc}%
\Huge}

% custom section
\titleformat{\section}
{\normalfont\Large\bfseries}
{\llap{\thesection\hskip 9pt}#1}
{0pt}
{}

% From the titlesec package
% \titlespacing{command}{left spacing}{before spacing}{after spacing}[right]
% spacing: how to read {12pt plus 4pt minus 2pt}
%           12pt is what we would like the spacing to be
%           plus 4pt means that TeX can stretch it by at most 4pt
%           minus 2pt means that TeX can shrink it by at most 2pt
%       This is one example of the concept of, 'glue', in TeX
\titlespacing{\chapter}{0pt}{*4}{-0.1cm}
\titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{-5pt plus 2pt minus 2pt}
\titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{-6pt plus 2pt minus 2pt}
\titlespacing\subsubsection{0pt}{12pt plus 4pt minus 2pt}{-6pt plus 2pt minus 2pt}

\begin{document}

\chapter{Introduction}

\end{document}

-