Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to prevent the issue of having titles superposed in the header of my report.

I am using the following code:

  \usepackage{fancyhdr}
  \setlength{\headheight}{15.2pt}
  \pagestyle{fancy}

Actually, when the current subsection is too long and the section as well, both titles are superposed in the middle of the header. Is there a way to prevent it? Thank you in advance!

EDIT

Typical example :

  \section{This is a supercalifragilisticexpialidocious title for a section}
  \newpage
  \subsection{I am also a supercalifragilisticexpialidocious subtitle}

When you check the header of the second page, section and subsection displayed are superposed. I wish I could have at least the entire text of the section and on the left part the start of the subsection with "..." before it becomes superposed.

ie, I wish I could have this kind of header :

  1.1 I am also a ...       1 THIS IS A SUPERCALIFRAGILISTICEXPIDALIDOCIOUS TITLE FOR A SECTION

EDIT 2

As requested, a minimum working example. It concerns the second page header.

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[francais]{babel}
\usepackage[T1]{fontenc}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}


\usepackage{fancyhdr}
\setlength{\headheight}{15.2pt}
\pagestyle{fancy}


\begin{document}
\section{This is a supercalifragilisticexpialidocious title for a section}
\newpage
  \subsection{I am also a supercalifragilisticexpialidocious subtitle}


\end{document}
share|improve this question
1  
Welcome to TeX.SX! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. You can have a look on our starter guide to familiarize yourself further with our format. –  egreg Jun 27 '13 at 7:36
1  
@Header12: you don't have to post your exact code, but a minimal working example, that is a document starting with \documentclass, ending with \end{document} which reproduces the problem. Furthermore, you just have to load the relevant packages able to reproduce the problem, not the whole preamble. :) –  Claudio Fiandrino Jun 27 '13 at 7:52
    
You should include an MWE. I don't know if it is possible to do that automatically, but what you could do is, you could use the following syntax of the \section / \subsection commands: \section[short title for headers]{long title} however, this also affects the TOC –  bene Jun 27 '13 at 8:00
    
It's necessary at leastu to know the fancyhdr settings you're using and the document class. Note that having both the section and subsection titles in a single header makes it easy to get superpositions, because the space is limited. –  egreg Jun 27 '13 at 8:03
    
Unfortunately the proposed solution is not working on the MWE I provided. Thank you in advance for any help you would proposed. Regards. –  Header12 Jun 27 '13 at 12:02

2 Answers 2

up vote 1 down vote accepted

I suggest you to use this answer and manually decide, case-by-case, what to show on the header. I think it's quite impossible do this automatically. As an example:

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[francais]{babel}
\usepackage[T1]{fontenc}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}%any chances to remove this?
\usepackage{lipsum}

\usepackage{fancyhdr}
\setlength{\headheight}{15.2pt}
\pagestyle{fancy}

\newcommand{\markedsection}[2]{
    \section[#2]{#2%
    \sectionmark{#1}}\sectionmark{#1}}

\newcommand{\markedsubsection}[2]{
    \subsection[#2]{#2%
    \subsectionmark{#1}} \subsectionmark{#1}} 

\begin{document}
\tableofcontents
\newpage

% \markedsection{HEADER}{PAGE AND TOC}
\markedsection{This is a supercalifragilisticexpialidocious title\dots}{This is a supercalifragilisticexpialidocious title for a section}
\lipsum

\markedsubsection{I am also a super\dots}{I am also a supercalifragilisticexpialidocious subtitle}
\lipsum[3]
\markedsubsection{Another veeery\dots}{Another very very very very very very long title}
\lipsum

\end{document}

screenshot

share|improve this answer

This is a MWE:

\documentclass{scrartcl}

\usepackage{fancyhdr}
\pagestyle{fancy}

\begin{document}
\tableofcontents
\newpage

\section[section toc]{section normal text}
\sectionmark{section header}

\subsection[subsec toc]{subsec normal text}
\subsectionmark{subsection header}

lorem ipsum
\newpage
lorem ipsum

\end{document}

it might not be as simple as I thought. Apparently your \usepackage[francais]{babel} gives some problem. I extended your code here:

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
%\usepackage[francais]{babel}
\usepackage[T1]{fontenc}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}


\usepackage{fancyhdr}
\setlength{\headheight}{15.2pt}
\pagestyle{fancy}


\begin{document}
\section{This is a supercalifragilisticexpialidocious title for a section}
\newpage
\subsection{I am also a supercalifragilisticexpialidocious subtitle%
%\subsectionmark{code1}%
}
\subsectionmark{code}

\newpage
lorem ipsum


\end{document}

you can see, the problem is that at the first page of the subsection, there is still the long header of the subsection. If you know uncomment the line with code1 everything looks like you want it. However, I uncommented the babel command as well, since I got an error message because of that and I don't know yet, how this can be solved.

share|improve this answer
    
Thank you for your answer. However, isn't there a command for treating this kind of issue automatically? Everytime I am using this kind of hand-made solutions, I find out that there is something already existing in latex. –  Header12 Jun 27 '13 at 8:20
    
The problem is, how shall the compiler decide, where to abbreviate? Therefore, it only gives you a warning and you can then decide, what to do against it. –  bene Jun 27 '13 at 8:31
    
Hello, Your solution is still not working. Could you please help me? Regards. –  Header12 Jun 27 '13 at 12:01

Your Answer

 
discard

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.
http://tex.stackexchange.com/questions/121290/prevent-superposition-of-titles-in-header-fancy
tex.stackexchange.com
crawl=CC-MAIN-2015-32
83567
application/http; msgtype=response
sha1:7GL6ZRZABWTY46ASP72IEDEJ6CMLD4GS
<urn:uuid:4f63e3d1-8d97-4b49-b324-abaf19224e71>
2015-07-30T00:26:06Z
104.16.12.13
sha1:RFCFQDUDVCXROWE5HEJJXCGHWXPHI722
<urn:uuid:7099613b-d660-4d4c-af19-59dacc45fa63>
http://tex.stackexchange.com/questions/121290/prevent-superposition-of-titles-in-header-fancy
length
response
<urn:uuid:a4064892-e15d-40c5-af3a-4de1634e0d67>
robots: classic
hostname: ip-10-236-191-2.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2015-32
operator: CommonCrawl Admin
description: Wide crawl of the web for August 2015
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf