¿Cómo hago un encabezado para todo el documento?

¿Cómo hago un encabezado para todo el documento?

Estaba buscando este tema. ¿Cómo podría solucionarlo?

Tengo un problema con el código cuando defino el encabezado:

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

Respuesta1

En esto:

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

tienes una "O" (la vocal) en lugar de un cero; aquí está su código con el cero corregido y algunas otras modificaciones (aumenté \headheightconvenientemente y en lugar de cargar colory colortbl, puede cargar xcolorcon la tableopción) y suprimió cierta información que no era relevante para el problema del encabezado:

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

Tenga en cuenta que sin un \chapterantes \sectionobtendrá una numeración impar.

información relacionada