# fancyhdr too long names of the sections, lines at the right and left

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.

1. So how can I have this correctly? So it does not look that stupid anymore.

2. 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{\section}

\titleformat{\subsection}

\titleformat{\subsubsection}

\titleformat{\paragraph}
\usepackage[ngerman]{babel}
\usepackage{mathptmx}
\usepackage{helvet}
\usepackage{wallpaper}
\usepackage{color}
\usepackage[final]{pdfpages}
%,bookmarksopenlevel={1}
hypertexnames=TRUE,pdfpagelabels=true]{hyperref}[2011/02/05]
\hypersetup{
pdftitle={},
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{amsthm}
\usepackage{amsmath}
\usepackage{marginnote}
%\usetocstyle{KOMAlike}
\usepackage{wrapfig}
\usepackage{paralist}
\usepackage{amssymb}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{ulem}
\usepackage{fancyhdr}
%\usepackage{sectsty}

\begin{document}
\mainmatter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagestyle{fancy}
\fancyhf{}

% 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:

-

\documentclass{article}
\usepackage{fancyhdr}
\usepackage{calc}
\usepackage{color}

\usepackage{lipsum}

\fancyhf{}

\begin{document}
\pagestyle{fancy}

\section[Short section name]{\lipsum[1]}
\lipsum[1]
\end{document}


-

For problem number one it is best if you provide a short title together with the section heading:

\section[Short section heading]{This is the equivalent long title that is typeset over several lines which is quite annoying. On a second note the title should probably be shorter}


I would highly recommend to limit your long titles, titles are titles, not self contained descriptions.

-
Ok, thanks a lot, and problem number 2? –  Heronimious Sep 4 '12 at 10:22