El encabezado y el pie de página de Fancyhdr desaparecen

El encabezado y el pie de página de Fancyhdr desaparecen

Tal como dice el título, mi encabezado y pie de página desaparecen aleatoriamente después de mi segunda página numerada.

Este es mi preámbulo:

% !TeX spellcheck = hr_HR
\documentclass[12pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[
 backend=bibtex      % biber or bibtex
,style=numeric-comp  % numerical-compressed
,sorting=none        % no sorting
,sortcites=true      % some other example options ...
,block=none
,indexing=false
,citereset=none
,isbn=true
,url=true
,doi=true            % prints doi
,natbib=true         % if you need natbib functions
]{biblatex}

\addbibresource{bibliografija.bib}
\nocite{*}

\usepackage{fancyhdr}
\usepackage{indentfirst}
\usepackage{setspace}
\usepackage[croatian]{babel}

\ifx\l@croatian\@undefined
    \@nopatterns{Croatian}
    \adddialect\l@croatian0\fi

\captionscroatian

\usepackage{graphicx}
\graphicspath{ {img/} }

\renewcommand{\contentsname}{Sadržaj}

\title{MVC arhitektura unutar AngularJS razvojnog okvira}
\author{Marko Klobučar}
\date{Lipanj, 2017.}

Los comandos que emití para iniciar el encabezado y el pie de página son los siguientes:

\pagestyle{fancy}
\fancyhf{}

\lhead{Sveučilište Sjever - Multimedija, oblikovanje i primjena}
\rhead{Marko Klobučar}
\rfoot{Stranica \thepage~od~\pageref{lastpage}}

\pagenumbering{arabic}

Y todo va bien durante dos páginas completas. Y de repente, el encabezado y el pie de página desaparecen en mi sexta página real, pero tercera numerada.

Lo siento muchísimo si esto ha sido respondido antes, busqué durante una hora y no pude encontrar lo que estaba buscando. También soy un completo principiante con el látex y agradecería cualquier ayuda.

¡Gracias de antemano! Por favor, avíseme si debo incluir algo que olvidé.

EDITAR: Aquí está el documento pequeño.

% !TeX spellcheck = hr_HR
\documentclass[12pt,a4paper]{article}

\usepackage[utf8]{inputenc}
%\usepackage[
% backend=bibtex
%]{biblatex}

% \addbibresource{bibliografija.bib}
% \nocite{*}

\usepackage{fancyhdr}
\usepackage{indentfirst}
\usepackage{setspace}
\usepackage[croatian]{babel}

\ifx\l@croatian\@undefined
    \@nopatterns{Croatian}
    \adddialect\l@croatian0\fi

\captionscroatian

\usepackage{graphicx}
\graphicspath{ {img/} }

\renewcommand{\contentsname}{Sadržaj}

\title{Title}
\author{Me}
\date{Now}

\begin{document}

\pagestyle{empty}
\pagenumbering{gobble}

\begin{titlepage}
    \maketitle
\end{titlepage}

\newpage
\tableofcontents
\newpage

\begin{spacing}{1.5}
\section*{Lorem ipsum.}
Lorem ipsum.

\newpage

\pagestyle{fancy}
\fancyhf{}

\lhead{Header left}
\rhead{John Doe}
\rfoot{Page \thepage~of~\pageref{lastpage}}

\pagenumbering{arabic}

\section{Sažetak}
Lorem ipsum dolor sit amet.
\newpage

\section{Uvod}
Lorem ipsum dolor sit amet.
\newpage

\section{Trouble!}
\subsection{This part is messed up.}
This section is where the header and footer disappear.

\subsection{Lorem ipsum.}
Lorem ipsum.

\end{spacing}
\newpage

\section{Popis literature}
\label{lastpage}
\vspace*{-1cm}
% \printbibliography[title=~]

\end{document}

Respuesta1

Aquí hay dos posibles códigos simples:

  • O usas el {spacing}{1.5}entorno y tienes que poner el último \newpagecomando justo antes \end{spacing}y repetirlo \pagestyle{fancy}justo después,
  • O usa el \onehalfspacingcomando y lo reemplaza \end{spacing}con \singlespacing.

Aquí están los códigos para la parte relevante:

Con el medio ambiente:

\begin{spacing}{1.5}
\section*{Predgovor}
Here's some text.

\newpage
\pagestyle{fancy}
\pagenumbering{arabic}

\section{Sažetak}
Lorem ipsum dolor sit amet.
\newpage

\section{Uvod}
Lorem ipsum dolor sit amet.
\newpage

\section{O tehnologiji}
\subsection{O pojmu arhitekture u softverskom razvoju}
Here's some text.

\subsection{Opis MVC arhitekture}
Here's some text.
\newpage
\end{spacing}

\pagestyle{fancy}

\section{Popis literature}
\label{lastpage}
\vspace*{-1cm}
\printbibliography[title=Bib]

Con los comandos:

\onehalfspacing

\section*{Predgovor}
Here's some text.
\newpage
\pagestyle{fancy}
\pagenumbering{arabic}

\section{Sažetak}
Lorem ipsum dolor sit amet.
\newpage

\section{Uvod}
Lorem ipsum dolor sit amet.
\newpage

\section{O tehnologiji}
\subsection{O pojmu arhitekture u softverskom razvoju}
Here's some text.

\subsection{Opis MVC arhitekture}
Here's some text.

\newpage
\singlespacing

\section{Popis literature}
\label{lastpage}
\vspace*{-1cm}
\printbibliography[title=Bib]

ingrese la descripción de la imagen aquí

Respuesta2

Resolví mi problema. El problema era que el encabezado y el pie de página terminaban justo después de que terminara la sección de espaciado, así que hice un ajuste manual y ahora funciona. Aquí está el código mínimo:

% !TeX spellcheck = hr_HR
\documentclass[12pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[
 backend=bibtex
]{biblatex}

\addbibresource{bibliografija.bib}
\nocite{*}

\usepackage{fancyhdr}
\usepackage{indentfirst}
\usepackage{setspace}
\usepackage[croatian]{babel}

\ifx\l@croatian\@undefined
    \@nopatterns{Croatian}
    \adddialect\l@croatian0\fi

\captionscroatian

\usepackage{graphicx}
\graphicspath{ {img/} }

\renewcommand{\contentsname}{Sadržaj}

\title{Here's some text.}
\author{Here's some text.}
\date{Lipanj, 2017.}

\fancyhf{}
\lhead{Here's some text.}
\rhead{Here's some text.}
\rfoot{Stranica \thepage~od~\pageref{lastpage}}

\begin{document}
\pagestyle{empty}
\pagenumbering{gobble}

\begin{titlepage}
    \maketitle

    \newpage

    \tableofcontents

    \newpage
\end{titlepage}

\begin{spacing}{1.5}
\section*{Predgovor}
Here's some text.
\newpage
\end{spacing}

\begin{spacing}{1.5}
\pagestyle{fancy}
\pagenumbering{arabic}

\section{Sažetak}
Lorem ipsum dolor sit amet.
\newpage

\section{Uvod}
Lorem ipsum dolor sit amet.
\newpage

\section{O tehnologiji}
\subsection{O pojmu arhitekture u softverskom razvoju}
Here's some text.

\subsection{Opis MVC arhitekture}
Here's some text.
\end{spacing}

\newpage
\pagestyle{fancy}

\section{Popis literature}
\label{lastpage}
\vspace*{-1cm}
\printbibliography[title=~]

\end{document}

No es lo más bonito pero hace lo que quería y eso es suficiente para mí.

Respuesta3

Editar Ahora veo el problema. Vea si la siguiente solución es aceptable para usted:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}

\usepackage{fancyhdr}
\usepackage{indentfirst}
\usepackage{setspace}
\usepackage[croatian]{babel}

\renewcommand{\contentsname}{Sadržaj}

\title{Title}
\author{Me}
\date{Now}

\fancyhf{}% head to be in preamble !
\lhead{Header left}
\rhead{John Doe}
\rfoot{Page \thepage~of~\pageref{lastpage}}

\begin{document}
\pagestyle{fancy}
\thispagestyle{empty}
\pagenumbering{gobble}

\begin{titlepage}
    \maketitle
\end{titlepage}

\newpage
\thispagestyle{plain}% or empty)
\tableofcontents

\newpage
\thispagestyle{plain}% or empty)
\begin{spacing}{1.5}
\section*{Lorem ipsum.}
Lorem ipsum.

\newpage
\section{Sažetak}
Lorem ipsum dolor sit amet.
\newpage

\newpage
\section{Uvod}
Lorem ipsum dolor sit amet.


\newpage
\section{Trouble!}
\subsection{This part is messed up.}
This section is where the header and footer disappear.

\subsection{Lorem ipsum.}
Lorem ipsum.

\end{spacing}

\newpage
%\thispagestyle{empty} % addin case if the Literature had not have fancypage style
\section{Popis literature}
\label{lastpage}
\end{document}

información relacionada