Fancyhdr ヘッダーとフッターが消える

Fancyhdr ヘッダーとフッターが消える

タイトルにもあるように、2 番目の番号付きページ以降、ヘッダーとフッターがランダムに消えてしまいます。

これは私の序文です:

% !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.}

ヘッダーとフッターを開始するために発行したコマンドは次のとおりです。

\pagestyle{fancy}
\fancyhf{}

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

\pagenumbering{arabic}

2 ページ全体ではすべて正常です。 ところが、突然、実際の 6 ページ目 (ただし 3 ページ目) のヘッダーとフッターが消えてしまいました。

すでに回答されている場合は大変申し訳ございません。1 時間検索しましたが、探していたものが見つかりませんでした。私も Latex の初心者なので、ご助力いただければ幸いです。

よろしくお願いします。忘れているものがあればお知らせください。

編集: ここに小さめの文書があります。

% !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}

答え1

以下に 2 つの簡単なコードを示します。

  • 環境を使用するか、最後のコマンドを直前に{spacing}{1.5}置き、直後に繰り返す必要があります。\newpage\end{spacing}\pagestyle{fancy}
  • または、\onehalfspacingコマンドを使用して、\end{spacing}を に置き換えます\singlespacing

関連する部分のコードは次のとおりです。

環境について:

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

次のコマンドを使用します:

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

ここに画像の説明を入力してください

答え2

問題は解決しました。問題は、ヘッダーとフッターがスペース セクションの直後に終了していたため、手動で折り返しを行ったところ、正常に動作するようになりました。最小限のコードは次のとおりです。

% !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}

あまりきれいなものではありませんが、私が望んでいたことは実現しているので、私にとってはそれで十分です。

答え3

編集 問題が分かりました。次の解決策が受け入れられるかどうか確認してください。

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

関連情報