Como faço um cabeçalho para todo o documento?

Como faço um cabeçalho para todo o documento?

Eu estava procurando por esse tópico. Como eu poderia resolver isso?

Tenho um problema com o código quando defino o cabeçalho:

\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}

Responder1

Nisso:

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

você tem um "O" (a vogal) em vez de zero; aqui está o seu código com o zero corrigido e algumas outras modificações (aumentei \headheightconvenientemente e em vez de carregar coloro and colortbl, você pode carregar xcolorcom a tableopção) e suprimi algumas informações que não eram relevantes para o problema do cabeçalho:

\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}

Observe que sem \chapterantes \sectionvocê obterá uma numeração ímpar.

informação relacionada