Chead 和 Cfoot 中的错误

Chead 和 Cfoot 中的错误

我正在写硕士论文。我面临以下错误:

LaTeX 错误:命令 \chead 已定义。或名称 \end... 非法,请参阅手册第 192 页。/usr/local/texlive/2018/texmf-dist/tex/latex/fancyhdr/fancyhdr.sty,第 101 行

LaTeX 错误:命令 \cfoot 已定义。或名称 \end... 非法,请参阅手册第 192 页。/usr/local/texlive/2018/texmf-dist/tex/latex/fancyhdr/fancyhdr.sty,第 107 行

我的代码如下:

\documentclass[a4paper,twoside]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
% package for including graphics with figure-environment
\usepackage{graphicx}
% package for bibliography
\usepackage{cite}
% package for header
\usepackage{subcaption}
\usepackage[automark]{scrlayer-scrpage}
\usepackage{float}
\usepackage{fancyhdr}
\usepackage{listings}
\usepackage{comment}
\usepackage{afterpage}
\KOMAoptions{headsepline=.4pt:head}
\renewcommand{\headrulewidth}{0.4pt}
\pagestyle{fancy}
\begin{document} 


\begin{figure}[!tbp]
  \centering
  \begin{minipage}[b]{0.4\textwidth}
    \includegraphics[width=\textwidth]{a.png}
  \end{minipage}
  \hfill
  \begin{minipage}[b]{0.4\textwidth}
    \includegraphics[width=\textwidth]{Logo.jpg}
  \end{minipage}
\end{figure}

    \title {
    \large{\bfseries Masgy \\ (ggg SS16)}\\
    \vspace{2cm}
    \Huge \textbf{ker (PT) \\}
    }

    \vspace{2cm}

    % if you are the only author, you might use the following
    \author{\textbf {Submitted by: ad}} 
    \vspace{1cm}

    % name of the course and module
    \date{
    \textbf {Master Thesis} \\ 
    \vspace{2cm}
    \large \textbf {Referees:} \\
    \large Prof. D\\
    \large Prof. D.\\
    \vspace{1cm}    
    \large \textbf {Developed at:} \\
    \large B\
    \vspace{1cm}    
    \large \textbf {Supervisors:} \\
    \large Dipl.-Ing. r\\
    \large Dipl.-Ing. aa\\
    \vspace{1cm}
    \today
    }

    \maketitle
    \setlength{\parindent}{0pt}
    \vspace{2cm}
    \newpage
    \thispagestyle{plain}
    \cleardoublepage
    \begin{center}
    \section*{STATUTORY DECLARATION}
    \end{center}
I, hereby declare that I have authored this thesis independently, that I have
not used other than the declared sources, and that I have explicitly marked all materials which has
been quoted either literally or by content from the used sources. I furthermore declare that this
thesis has not been submitted to any other board of examiners yet.
\\
\\
\\
\\
v, January 5, 2020
    \thispagestyle{plain}
    \newpage
    \thispagestyle{plain}
    \cleardoublepage
    \pagenumbering{roman}
    \thispagestyle{fancy}
    \cfoot{ }
    \renewcommand{\headrulewidth}{0pt}
    \begin{center}
\section*{Abstract}
    \end{center}
    hi, how are you
    \addcontentsline{toc}{section}{Abstract}
    \newpage
    \thispagestyle{plain}
    \cleardoublepage
    \thispagestyle{fancy}
    \cfoot{ }
    \renewcommand{\headrulewidth}{0pt}
    \begin{center}
\section*{Acknowledgments}
    \end{center}
    \addcontentsline{toc}{section}{Acknowledgement}
    \newpage
    \thispagestyle{plain}
    \cleardoublepage
    \thispagestyle{fancy}
    \cfoot{ }
    \renewcommand{\headrulewidth}{0pt}
    \begin{center}
\section*{Abbreviations}
    \end{center}
    \addcontentsline{toc}{section}{Abbreviations}
    \newpage
    \thispagestyle{empty}
    \tableofcontents
    \newpage
    \thispagestyle{empty}
    \listoffigures
    \newpage
    \thispagestyle{empty}
    \listoftables
    \newpage

\pagenumbering{arabic}
\setcounter{page}{1}    
\renewcommand{\headrulewidth}{1pt}
\section{Introduction} % (fold)
\label{sec:introduction}
interactive proofs and secure computation, among others.\cite{waghmarehistory}

\section{Historical Background} % (fold)
\label{sec:history}
to spies in "secret writing".\cite{waghmarehistory}


\section{End to End Encryption} % (fold)
\label{sec:e2e_encryption}

from the cryptographic community.\cite{isobe2018breaking}

\subsection{Pretty Good Privacy (PGP)} % (fold)
\label{sub:subsection_pgp}
OpenPGP .\cite{pgpcreator}


\newpage 

\bibliographystyle{IEEEtran}
    \bibliography{references} % expects file "references.bib"
\end{document}

非常感谢您的帮助。

答案1

在您的例子中,您尝试使用两个包scrlayer-scrpagefancyhdr。罪魁祸首是包scrlayer-scrpage定义并使用例如命令\cfoot。通过调用第二个包,fancyhdr该包还尝试定义和使用自己的命令\cfoot,但这是不可能的,因为该命令已经定义并正在使用中...

因此,您的解决方案是仅使用(如果您使用类或或,scrlayer-scrpage我建议您这样做)。 因为您正在使用类,所以我建议使用包。scrartclscrreprtscrbookarticlefancyhdr

因此,请仔细查看以下 MWE,其中我评论了您所有错误使用的命令,并添加了一些带有注释的新命令,例如% <=======带有或不带有解释...

现在,您的页面编号已经一致,页码会显示在需要的位置,而不会显示在标题页上...

\documentclass[a4paper,twoside]{article}

\usepackage{showframe} % <===== to visualize typing area and margins ===
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
% package for including graphics with figure-environment
\usepackage{graphicx}
% package for bibliography
\usepackage{cite}
% package for header
\usepackage{subcaption}
%\usepackage[automark]{scrlayer-scrpage} % <============================
\usepackage{float}
\usepackage{fancyhdr}
\usepackage{listings}
\usepackage{comment}
\usepackage{afterpage}
%\KOMAoptions{headsepline=.4pt:head} % <================================
\renewcommand{\headrulewidth}{0.4pt}
%\pagestyle{fancy}


\begin{document} 

\pagenumbering{roman} % <===============================================
\pagestyle{empty} % <===================================================

\begin{figure}[!tbp]
  \centering
  \begin{minipage}[b]{0.4\textwidth}
    \includegraphics[width=\textwidth]{example-image-a.png}
  \end{minipage}
  \hfill
  \begin{minipage}[b]{0.4\textwidth}
    \includegraphics[width=\textwidth]{example-image-b}
  \end{minipage}
\end{figure}

\title {
    \large{\bfseries Masgy \\ (ggg SS16)}\\
    \vspace{2cm}
    \Huge \textbf{ker (PT) \\}
    }

    \vspace{2cm}

    % if you are the only author, you might use the following
\author{\textbf {Submitted by: ad}} 
    \vspace{1cm}

    % name of the course and module
\date{
    \textbf {Master Thesis} \\ 
    \vspace{2cm}
    \large \textbf {Referees:} \\
    \large Prof. D\\
    \large Prof. D.\\
    \vspace{1cm}    
    \large \textbf {Developed at:} \\
    \large B\
    \vspace{1cm}    
    \large \textbf {Supervisors:} \\
    \large Dipl.-Ing. r\\
    \large Dipl.-Ing. aa\\
    \vspace{1cm}
    \today
    }

\maketitle
\thispagestyle{empty} % <===============================================
    \setlength{\parindent}{0pt}
    \vspace{2cm}
\newpage
   \pagestyle{plain} % <================================================
    \cleardoublepage
    \begin{center}
    \section*{STATUTORY DECLARATION}
    \end{center}
I, hereby declare that I have authored this thesis independently, that I have
not used other than the declared sources, and that I have explicitly marked all materials which has
been quoted either literally or by content from the used sources. I furthermore declare that this
thesis has not been submitted to any other board of examiners yet.
\\
\\
\\
\\
v, January 5, 2020
%   \thispagestyle{plain}
\newpage
%   \thispagestyle{plain}
    \cleardoublepage
%   \pagenumbering{roman}
%   \thispagestyle{fancy}
%   \cfoot{ }
    \renewcommand{\headrulewidth}{0pt}
    \begin{center}
\section*{Abstract}
    \end{center}
    hi, how are you
    \addcontentsline{toc}{section}{Abstract}
    \newpage
%   \thispagestyle{plain}
    \cleardoublepage
%   \thispagestyle{fancy}
%   \cfoot{ }
    \renewcommand{\headrulewidth}{0pt}
    \begin{center}
\section*{Acknowledgments}
    \end{center}
    \addcontentsline{toc}{section}{Acknowledgement}
    \newpage
%   \thispagestyle{plain}
    \cleardoublepage
%   \thispagestyle{fancy}
%   \cfoot{ }
    \renewcommand{\headrulewidth}{0pt}
    \begin{center}
\section*{Abbreviations}
    \end{center}
    \addcontentsline{toc}{section}{Abbreviations}
    \newpage
%   \thispagestyle{empty}
    \tableofcontents
    \newpage
%   \thispagestyle{empty}
    \listoffigures
    \newpage
%   \thispagestyle{empty}
    \listoftables
    \newpage

\pagenumbering{arabic}
\pagestyle{fancy} % <===================================================
%\setcounter{page}{1} % <===============================================
\renewcommand{\headrulewidth}{1pt}
\section{Introduction}
\label{sec:introduction}
interactive proofs and secure computation, among others.\cite{waghmarehistory}

\section{Historical Background} % (fold)
\label{sec:history}
to spies in "secret writing".\cite{waghmarehistory}


\section{End to End Encryption} % (fold)
\label{sec:e2e_encryption}

from the cryptographic community.\cite{isobe2018breaking}

\subsection{Pretty Good Privacy (PGP)} % (fold)
\label{sub:subsection_pgp}
OpenPGP .\cite{pgpcreator}


\newpage 

\bibliographystyle{IEEEtran}
    \bibliography{references} % expects file "references.bib"
\end{document}

以及由此产生的标题页

在此处输入图片描述

以及结果目录

在此处输入图片描述

顺便说一句:内容和所有章节标题都格式化为左对齐,只有摘要直到缩写标题格式化为居中。这看起来不太好看,所有标题都使用相同的格式!

相关内容