Fancyhdr 頁首和頁尾消失

Fancyhdr 頁首和頁尾消失

如標題所說,我的頁首和頁尾在第二頁編號後隨機消失。

這是我的序言:

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

整整兩頁都一切順利。然後突然頁首和頁尾消失在我的第六頁,但第三頁。

如果之前已經回答過這個問題,我感到非常抱歉,我搜尋了一個小時,但找不到我要找的東西。我也是乳膠的初學者,非常感謝任何幫助。

先感謝您!請告訴我是否應該添加我忘記的內容。

編輯:這是一個小文件。

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

這是兩個可能的簡單程式碼:

  • 要么使用{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}

相關內容