# section title and page number overlapping in heading; fancyhdr

I have set the headings to show the section number and name on the left side of the page, and the page number on the right.

This works fine for most section names, but one particular one is a little long, but not long enough (it seems): it just overlaps the page number, but not enough to make LaTeX wrap automatically. (I have a longer heading and LaTeX notices this and does the right thing.)

I changed the section name to

\section[really long section\\name]{really long section name}

which works in the header fine, but (obviously) also makes a newline in the TOC. The section name fits the TOC fine, so:

Is it possible to force a newline in the header, but not the TOC entry?

This is how my preamble looks:

\usepackage{fancyhdr}
\pagestyle{fancy}

% with this we ensure that the Chapter and Section
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}{}}

\fancyhf{}                              % delete the current header and footer

\fancypagestyle{plain}{
\fancyfoot[R]{\textbf{\thepage}}
}
-
You can use \markboth{}{}. You will find a lot of examples at tex stackexchange. –  Marco Daniel Mar 21 '12 at 19:24
multi-line running heads aren't usually a good idea. \markboth with a shorter form for the running head would be better. –  barbara beeton Mar 21 '12 at 19:40
@MarcoDaniel thanks. I searched round (and elsewhere), and experimented, but can't get what I want. I've edited my question to show the preamble I'm using (book class, oneside). –  Chris Poole Mar 21 '12 at 20:15
@barbarabeeton could you explain in more detail what you mean please? I tried changing \markright to \markboth when renewing the \sectionmark command, to no avail. –  Chris Poole Mar 22 '12 at 12:20

Instead of using \\ create a new macro with, say, \DeclareRobustCommand\NL{ } and redefine it locally in the headers with \DeclareRobustCommand\NL{\\}. Then write:

\section[really long section\NL name]{really long section name}
-

Put your fancy head in LO inside a parbox as shown below:

\fancyhf{}                              % delete the current header and footer

And do not use \\ in short title: \section[really long section\\name]{really long section name}

EDIT: You may use

\fancyhf{}                              % delete the current header and footer
\fancyhead[LO]{\parbox[t]{0.9\textwidth}{\textbf{\rightmark}}} %<--- use [t] for parbox.
\fancyhead[RO]{\parbox[t]{0.02\textwidth}{\textbf{\thepage}}} %<--- better use [t]  here also for parbox to ensure that alignment.