3

I was looking for this topic. How could I solve it?

I have an issue with the code, when I define the header:

\documentclass[12pt,a4paper]{book}
\title{\textbf{TITLE}}
\usepackage[spanish]{babel}
\usepackage{pdflscape}
\usepackage{color, colortbl}
\definecolor{Gray}{gray}{0.9}
\usepackage{caption}
\usepackage{enumitem}

\captionsetup[table]{skip=10pt}
\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}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\headheight}{0.5pt}
\fancypagestyle{plain}{
    \fancyhead{}
    \renewcommand{\headrulewidth}{Opt}
}

\begin{document}

\maketitle
\newpage
\tableofcontents

\section{RESUMEN EJECUTIVO}
\begin{enumerate}[label=\Alph*]
\item Los Par\'asitos
\item Cuantificar
\end{enumerate}

\end{document}
5
  • 2
    Use fancyhdr.
    – user11232
    Commented Dec 12, 2012 at 13:33
  • Please, give some more information. What class are you using? What form should this header have?
    – egreg
    Commented Dec 12, 2012 at 13:37
  • I got an error. This is the code. Is there something wrong?
    – Isai
    Commented Dec 12, 2012 at 13:38
  • 1
    The in the \renewcommand{\headrulewidth}{Opt}, the last argument should be 0pt (a zero), instead of an uppercase O. Also, if you are writting in spanish, you may want to use the inputenc package: \usepackage[utf8]{inputenc}, so you can write "parásitos" directly.
    – guillem
    Commented Dec 12, 2012 at 14:01
  • @guillem Good point, I mean for spanish writing. Thanks a lot.
    – Isai
    Commented Dec 12, 2012 at 19:09

1 Answer 1

3

In this:

\fancypagestyle{plain}{
    \fancyhead{}
    \renewcommand{\headrulewidth}{Opt}
}

you have an "O" (the vowel) instead of a zero; here's your code with the corrected zero and some other modifications (I increased \headheight conveniently and instead of loading color and colortbl, you can load xcolor with the table option) and suppressed some information that was not relevant to the header issue:

\documentclass[12pt,a4paper]{book}
\usepackage[spanish]{babel}
\usepackage{pdflscape}
\usepackage[table]{xcolor}
\usepackage{caption}
\usepackage{enumitem}
\usepackage{fancyhdr}

\definecolor{Gray}{gray}{0.9}
\captionsetup[table]{skip=10pt}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\setlength{\headheight}{14.5pt}
\fancypagestyle{plain}{
    \fancyhead{}
    \renewcommand{\headrulewidth}{0pt}
}
\renewcommand{\chaptermark}[1]{
    \markboth{#1}{}}
\renewcommand{\sectionmark}[1]{
    \markright{\thesection\ #1}}

\begin{document}

\section{RESUMEN EJECUTIVO}
\begin{enumerate}[label=\Alph*]
\item Los Par\'asitos
\item Cuantificar
\end{enumerate}

\end{document}

Note that without a \chapter before \section you'll get an odd numbering.

4
  • Thanks, I also got it with: \usepackage{fancyhdr} \usepackage{lipsum} \pagestyle{fancy} \headheight=10pt \fancyhf{} \lhead{TITLE} \thispagestyle{fancy} But I have another question: I want a small font for the header.
    – Isai
    Commented Dec 12, 2012 at 14:02
  • @Isai use an appropriate font size switch; for example: \fancyhead[LE,RO]{\bfseries\footnotesize\thepage} \fancyhead[LO]{\bfseries\footnotesize\rightmark} \fancyhead[RE]{\bfseries\footnotesize\leftmark} Commented Dec 12, 2012 at 14:10
  • I use this code, in the preamble: \usepackage{fancyhdr} \pagestyle{fancy} \lhead{}%It means, blank \chead{}%Blank \rhead{\footnotesize{TITLE\\ \textbf{Title}}} \lfoot{} \cfoot{} \rfoot{\thepage} \renewcommand{\headrulewidth}{0.4pt} \renewcommand{\footrulewidth}{0.4pt} Thanks for your help!
    – Isai
    Commented Dec 12, 2012 at 19:07
  • 1
    @Isai You're welcome! I'm glad I could help. By the way, \fotnotesize does not receive arguments, so you could use \rhead{\footnotesize TITLE\\ \textbf{Title}}. Commented Dec 12, 2012 at 19:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .