I am using fancyhdr for my header. The problem is, that some of my section names are too long and it looks quite stupid. I attached a screenshot.
So how can I have this correctly? So it does not look that stupid anymore.
Then my second question is: I want to have a line on the left and on the right (not above), I also attached a screenshot how it should look like (they should be the same as the line under it).
Here is my code:
\documentclass{book}
\usepackage{geometry}
\geometry{left=4cm,right=3cm, top=2cm, bottom=2cm}
\usepackage[pagestyles]{titlesec}
\titlespacing*{\chapter}{0pt}{-30pt}{20pt}
\titleformat{\chapter}[display]{\color{headercolor}\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titleformat{\section}
{\color{headercolor}\normalfont\Large\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
{\color{headercolor}\normalfont\Large\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}
{\color{headercolor}\normalfont\large\bfseries}{\thesubsubsection}{1em}{}
\titleformat{\paragraph}
{\color{headercolor}\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\usepackage[ngerman]{babel}
\usepackage{mathptmx}
\usepackage{helvet}
\usepackage{wallpaper}
\usepackage{color}
\usepackage[final]{pdfpages}
%,bookmarksopenlevel={1}
%\usepackage[hidelinks,bookmarks=true,bookmarksopen=true,bookmarksnumbered=true,colorlinks=true,linkcolor=black,]{hyperref}
\usepackage[colorlinks,linkcolor=black,bookmarksopen=false,
hypertexnames=TRUE,pdfpagelabels=true]{hyperref}[2011/02/05]
\hypersetup{
pdftitle={},
% pdfauthor={\textcopyright },
pdfsubject={Statistics book},
pdfkeywords={},
}
\usepackage{xcolor,bookmark}
\usepackage{scrextend}
\usepackage{titlepic}
\usepackage{shorttoc}
\usepackage{courier}
%\usepackage[titles]{tocloft}
\usepackage{type1cm}
\usepackage{zref-abspage}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage[bottom]{footmisc}
\usepackage{tocstyle}
\usetocstyle{allwithdot}
%\usepackage{thmbox}
\usepackage{shadethm}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{marginnote}
%\usetocstyle{KOMAlike}
\usepackage{wrapfig}
\usepackage{paralist}
\usepackage{amssymb}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{ulem}
\usepackage{fancyhdr}
%\usepackage{sectsty}
\definecolor{headercolor}{rgb}{0.6941,0.6745,0.4863}
\setlength{\headheight}{21pt}%
\begin{document}
\mainmatter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagestyle{fancy}
\fancyhf{}
%\fancyhead[L]{\parbox{0.7\textwidth}{\textbf{ \textcolor{headercolor}\leftmark\text{ }\textcolor{headercolor}{\rightmark}}}}
\fancyhead[L]{ \textcolor{headercolor}\leftmark \text{ }\textcolor{headercolor}{\rightmark}}%\thesection
\fancyhead[R]{\textcolor{headercolor}{\thepage}}
%\renewcommand{\headrule}{\vbox to 0pt{\hbox
%to\headwidth{\textcolor{headercolor}{\hrulefill}}\vss}}
%%\renewcommand{\headrulewidth}{2pt}
\renewcommand{\headrulewidth}{2pt}% 2pt header rule
\renewcommand{\headrule}{\vbox to 0pt{\hbox
to\headwidth{\textcolor{headercolor}{\rule{\linewidth}{\headrulewidth}}}\vss}}
% here comes the sections part, I commented to have a running sample:
%\include{part1}
%\include{chapter1}
% There I have those sections like
\section{very long text, really long, too long text, this looks not good but the names have to be like they are, yeah, really long, ..... ..... ..... ..... ..... ..... ..... ..}
text text\\text\\text\\text\\text and so on
\end{document}
Here is the screenshot: Problem 1:


Problem 2:

