TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


% with this we ensure that the Chapter and Section
% headings are in lowercase
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}{}}

\fancyhf{}                              % delete the current header and footer


\fancyhead{}                            % get rid of the headers on plain pages
\renewcommand{\headrulewidth}{0pt}      % and the line
share|improve this question
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

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

\fancyhf{}                              % delete the current header and footer
\fancyhead[LO]{\parbox{0.7\textwidth}{\textbf{\rightmark}}}% <----\parbox here.

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.

Also to adjust the head separation you can use

\setlength{\headsep}{0.25in} % <---change the value accordingly

enter image description here

share|improve this answer
Thanks. That did work (also for 0.95 * textwidth), but unfortunately it moves all headings slightly (perhaps 3/8 em or something) down, relative to the page number. – Chris Poole Mar 22 '12 at 12:18
@ChrisPoole, I have edited the answer accordingly. – Harish Kumar Mar 22 '12 at 13:39

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

Your Answer


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.