Page LayoutHelp for headers

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am

Help for headers

Post by NELLLY »

Hi
I need to get chapter headers for my report. I made some research with google and I liked the following format heading (http://www.apprendre-latex.images-en-fr ... e-page.php)

Code: Select all

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhf{} \fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\renewcommand{\headrulewidth}{0.5pt}
\addtolength{\headheight}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{ \fancyhead{}
\renewcommand{\headrulewidth}{0pt}} 
\begin{document}
\title{...} \hyphenpenalty 10000
\listoftables \listoffigures
\include{chap1}
But, when I typset the file, I obtain the word CONTENT in all chapter's headers and the line below the header footnote does not appear too where is the problem

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Help for headers

Post by gmedina »

Hi,

unless you provide a minimal working example showing the undesired bahaviour mentioned, there's no effective way to detect the problem.

The following simple example works OK in my system (I attach the resulting pdf):

Code: Select all

\documentclass{report}
\usepackage{fancyhdr}
\usepackage{lipsum}% just to generate some text

\pagestyle{fancy}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}

\fancyhf{} 
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\renewcommand{\headrulewidth}{0.5pt}
\addtolength{\headheight}{0.5pt}
\renewcommand{\footrulewidth}{0pt}

\fancypagestyle{plain}{%
  \fancyhead{}
  \renewcommand{\headrulewidth}{0pt}} 

\begin{document}

\tableofcontents
\chapter{Test chapter}
\lipsum[1]
\section{Test section one one}
\lipsum[1-20]
\section{Test section one two}
\lipsum[1-20]

\end{document}
Attachments
test.pdf
(66.93 KiB) Downloaded 227 times
1,1,2,3,5,8,13,21,34,55,89,144,233,...
NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am

Help for headers

Post by NELLLY »

Hi gmedina
thanks for the solution. I tried the commands for a document of style
\chapter{}
Text
\section{}Text
appearing in the main document and it works well. However, for my report document I still face the same problem. I don't know why but think this is because I use \include{chapter}. These are full commands I used in the main file.

Code: Select all


\documentclass [12pt]{report}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setlength{\topmargin} {-1cm} \setlength{\headheight} {1.5cm}
\setlength{\headsep} {1cm} \setlength{\oddsidemargin} {1cm}
\setlength{\textheight} {21cm} \setlength{\textwidth} {15cm}
\renewcommand{\baselinestretch}{1.5}
%\makeatletter
%\renewcommand*\l@section{\@dottedtocline{1}{0em}{2.3em}}
%\renewcommand*\l@subsection{\@dottedtocline{2}{0em}{3.2em}}
%\makeatother
\setcounter{tocdepth}{4} \setcounter{secnumdepth}{3}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[pdftex]{graphicx}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{titletoc}
%\usepackage{fancychapters}
\usepackage{float}
\usepackage{tabularx}
\usepackage{rotating}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{fancyhdr}
\pagestyle{fancy}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}

\fancyhf{} \fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\renewcommand{\headrulewidth}{0.5pt}
\addtolength{\headheight}{0.5pt}
\renewcommand{\footrulewidth}{0pt}

\fancypagestyle{plain}{%
  \fancyhead{}
  \renewcommand{\headrulewidth}{0pt}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




\begin{document}

\title{Thesis'title}
%\maketitle%
\titleformat{\chapter}[display]
{\normalfont\Large\filcenter\sffamily}
{\titlerule[1pt]%
\vspace{1pt}%
\titlerule
\vspace{1pc}%
\LARGE\MakeUppercase{\chaptertitlename} \thechapter} {1pc}
{\titlerule
\vspace{1pc}%
\Huge}





\tableofcontents \pagestyle{myheadings} \hyphenpenalty 10000
\listoftables \listoffigures
\include{chap1}
%\include{chap2_section1}
%\include{section2}
%\include{chap2_section1}
%\include{section}

%\include{biblio}
%\include{appendix}






\end{document}


User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Help for headers

Post by gmedina »

Hi,

the \pagestyle{myheadings} command placed right after \tableofcontents changes the headings back to the myheadings style, so the definitions that you made using fancyhdr will have no effect. Delete the \pagestyle{myheadings} command.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am

Re: Help for headers

Post by NELLLY »

This works well now.
Many thanks.
Post Reply