Text FormattingPreventing text wrapping in fancyhdr headers

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
gkamel
Posts: 25
Joined: Thu Oct 30, 2008 1:53 pm

Preventing text wrapping in fancyhdr headers

Post by gkamel »

Hello,

I am using fancyhdr to print the section and subsection name as follows

Code: Select all

\fancyhead{\leftmark~::~\rightmark}
however, fancyhdr wraps it just before the text reaches the centre header position. Is there a way of preventing the text from wrapping? I have checked the manual, these forums, and googled it, but no joy.

Thanks a lot.
George Kamel

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Preventing text wrapping in fancyhdr headers

Post by localghost »

Putting the header contents into a box might help.

Code: Select all

\fancyhead{\mbox{\leftmark~::~\rightmark}}

Best regards
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
gkamel
Posts: 25
Joined: Thu Oct 30, 2008 1:53 pm

Preventing text wrapping in fancyhdr headers

Post by gkamel »

Thanks, Thorsten, but LaTeX throws up an error as there is a linebreak in an \mbox due to the wrapping.

NB. the code in my first post should have read:

Code: Select all

\fancyhead[L]{\leftmark~::~\rightmark}
(missing the [L]). But regardless of this, the wrapping issue remains.
George Kamel
gkamel
Posts: 25
Joined: Thu Oct 30, 2008 1:53 pm

Re: Preventing text wrapping in fancyhdr headers

Post by gkamel »

It turns out that the problem is unique to my document, as the headers do not wrap if I use a minimal document. So I'll try to cut down my document to see what could be causing it, and post anything back here that may be of use to others.

Thanks.
George Kamel
Post Reply