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 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}
share|improve this question
2  
Use fancyhdr. –  Harish Kumar Dec 12 '12 at 13:33
    
Please, give some more information. What class are you using? What form should this header have? –  egreg Dec 12 '12 at 13:37
    
I got an error. This is the code. Is there something wrong? –  Isai Dec 12 '12 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 Dec 12 '12 at 14:01
    
@guillem Good point, I mean for spanish writing. Thanks a lot. –  Isai Dec 12 '12 at 19:09

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
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 Dec 12 '12 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} –  Gonzalo Medina Dec 12 '12 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 Dec 12 '12 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}}. –  Gonzalo Medina Dec 12 '12 at 19:16

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.