8

I'm having a problem with \chapter*{} and fancyhdr. I want to start the first chapter of my thesis with a introduction section, appearing in the TOC but without numeration, that's why I use:

\chapter*{Introduccion} 

and

\addcontentsline{toc}{chapter}{Introduccion}

at the beginning of the Introduccion.tex file, but I don't know why, the fancyhdr header shows "list of tables" instead of "Introduccion"!

(the list of tables is immediately before the introduction).

Here is my code:

\documentclass[a4paper,12pt,twoside]{book}
%
\usepackage[bottom=25mm,top=25mm, left=30mm, right=25mm]{geometry}
%
\parskip=8pt
%
\widowpenalty=10000
\clubpenalty=10000
%
\usepackage[spanish, es-tabla]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{morefloats}
%
\setcounter{secnumdepth}{3}
\usepackage{eurosym}
\usepackage[pdftex]{graphicx}
\usepackage{pdfpages}
\usepackage[pagebackref=true]{hyperref}
\hypersetup{%
    bookmarks=true,         % barra de marcadores
    unicode=false,          % caracteres non-Latin en marcadores de Acrobat
    pdftoolbar=true,        % mostrar barra de herramientas de Acrobat
    pdfmenubar=true,        % mostrar menú de Acrobat
    pdffitwindow=false,     % ajustar ventana al ancho de página
    pdfstartview={FitH},    % ajustar documento al ancho de página
    pdftitle={Memoria PFC}, % título
    pdfauthor={},           % autor
    pdfsubject={},          % tema del documento
    pdfcreator={},          % generador del documento
    pdfproducer={},         % productor del documento
    pdfkeywords={},         % lista de palabras clave
    pdfnewwindow=true,      % enlaces en una nueva ventana
    colorlinks=true,        % false: enlaces en caja; true: enlaces coloreados
    linkcolor=blue,         % color de enlaces internos
    citecolor=green,        % color de enlaces a bibliografía
    filecolor=magenta,      % color de enlaces a ficheros
    urlcolor=blue           % color de enlaces externos
}
%
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[EL]{\nouppercase\leftmark}
\fancyhead[OR]{\nouppercase\rightmark}
\fancyhead[ER,OL]{\thepage}
%
\makeatletter
%
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
  \hbox{}
  \thispagestyle{empty}
  \newpage
  \if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother
%
\begin{document}
%
\pagenumbering{gobble} % Las primeras paginas no quiero que se numeren
%
\includepdf[pages={-}]{./Archivos/Portada_PFCccompleto.pdf}
\input{./Archivos/Capitulos/pfc_dedicatoria}
\input{./Archivos/Capitulos/pfc_agradecimientos}
\include{./Archivos/Capitulos/pfc_abreviaturas}
%
% FRONTMATTER: TOC, LOF, LOT 
\frontmatter
%
\tableofcontents
\listoffigures
\listoftables
%
% MAINMATTER
%
\mainmatter
\include{./Archivos/Capitulos/pfc_intro}
\include{./Archivos/Capitulos/pfc_main_010}
...
%
  • 4
    This is a very common problem. Add \markboth{Introduccion}{Introduccion} after \chapter*{Introduccion}. By the way, instead of redefining \cleardoublepage, you can add \usepackage{emptypage} – egreg Oct 20 '13 at 18:59
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Andrew Swann Oct 20 '13 at 19:19
  • It might already help if you move the introduction to the \frontmatter and use a normal \chapter. An alternative could be to use a class and »scrpage2« from »KOMA-Script« and use its \addchap command. – Thorsten Donig Oct 21 '13 at 7:41
6

This is a very common problem. The \chapter* command doesn't update the marks that are used for the headers, while \listoftables does.

So the result is that after

\mainmatter
\chapter*{Introduccion}

The simplest and more effective remedy is to issue

\markboth{Introduccion}{Introduccion}

since you're removing the usual uppercasing done by the book class; you could also, for doing like the \listof... commands, type

\markboth{\MakeUppercase{Introduccion}}{\MakeUppercase{Introduccion}}

so the style will be the same even if you eventually decide not to use fancyhdr.

However, the best option, in my opinion, is to number also the introduction and forget about all these problems.


A couple of words about your style. I prefer to have a package loading section and then a setup section in the preamble. Also, pdftex should not be passed to graphicx. Instead of redefining \cleardoublepage it's simpler to load the emptypage package.

I removed the settings to \clubpenalty and \widowpenalty to 10000, because this doesn't really solve the problems with club and widow lines. Reinstate them, if you prefer. Also setting a nonzero parskip should be avoided: it hinders readability rather than enhancing it, particularly in presence of short paragraphs, producing loads of white strips on the page.

Last, I added headheight=14.5pt as requested by fancyhdr.

Here's an edited version (kantlipsum is just for producing some nonsense text).

\documentclass[a4paper,12pt,twoside]{book}

\usepackage[
  bottom=25mm,
  top=25mm,
  left=30mm,
  right=25mm,
  headheight=14.5pt,
]{geometry}

\usepackage[utf8]{inputenc}
\usepackage[spanish, es-tabla]{babel}

\usepackage{kantlipsum} % for populating the document

\usepackage{morefloats}
\usepackage{eurosym}
\usepackage{graphicx}
\usepackage{pdfpages}
\usepackage{fancyhdr}
\usepackage{emptypage}
\usepackage[pagebackref=true]{hyperref}
\hypersetup{%
    bookmarks=true,         % barra de marcadores
    unicode=false,          % caracteres non-Latin en marcadores de Acrobat
    pdftoolbar=true,        % mostrar barra de herramientas de Acrobat
    pdfmenubar=true,        % mostrar menú de Acrobat
    pdffitwindow=false,     % ajustar ventana al ancho de página
    pdfstartview={FitH},    % ajustar documento al ancho de página
    pdftitle={Memoria PFC}, % título
    pdfauthor={},           % autor
    pdfsubject={},          % tema del documento
    pdfcreator={},          % generador del documento
    pdfproducer={},         % productor del documento
    pdfkeywords={},         % lista de palabras clave
    pdfnewwindow=true,      % enlaces en una nueva ventana
    colorlinks=true,        % false: enlaces en caja; true: enlaces coloreados
    linkcolor=blue,         % color de enlaces internos
    citecolor=green,        % color de enlaces a bibliografía
    filecolor=magenta,      % color de enlaces a ficheros
    urlcolor=blue           % color de enlaces externos
}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[EL]{\nouppercase\leftmark} 
\fancyhead[OR]{\nouppercase\rightmark}
\fancyhead[ER,OL]{\thepage}

\setcounter{secnumdepth}{3}

\begin{document}

\frontmatter

\tableofcontents
\listoffigures
\listoftables

\mainmatter

\chapter*{Introduccion}
\markboth{Introduccion}{Introduccion}

\kant

\chapter{Abc}

\section{Def}

\kant

\begin{table}
\caption{X}
\end{table}

\begin{figure}
\caption{Y}
\end{figure}

\kant

\end{document}

enter image description here

0

Try de-activating properties that you define of fancyhdr package, then put your chapter and your text and finally activates fancy properties again, but you have to be careful locating the lines to reactivate it:

\listoftables  
\fancyhf{} % sets both header and footer to nothing
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\chapter*{my-chapter-name}
\blindtext   
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% NOTE: PAY ATTENTION HERE %%%%%%%%%%
%%%%
%%%%    If the text after the '\chapter*{my-chapter-name}':
%%%%    is more than one page, the lines after this note  should 
%%%%    be exactly after the first paragraph of the second page
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    
\pagestyle{fancy}                   
\fancyfoot{}
\fancyhead{}
\fancyhead[L]{\scriptsize \leftmark}
\fancyfoot[L]{\scriptsize \rightmark}
\fancyhead[R]{\thepage}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0.5pt}
  • Note that this removes the header altogether. – Werner Dec 10 '18 at 5:58
  • Thanks for the replay and correction, my native language is spanish, but I try my best in English – Cruz E Dec 11 '18 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.