# Error in Chead and Cfoot

I am writing my master thesis. I am facing the following errors:

LaTeX Error: Command \chead already defined. Or name \end... illegal, see p.192 of the manual. /usr/local/texlive/2018/texmf-dist/tex/latex/fancyhdr/fancyhdr.sty, line 101

LaTeX Error: Command \cfoot already defined. Or name \end... illegal, see p.192 of the manual. /usr/local/texlive/2018/texmf-dist/tex/latex/fancyhdr/fancyhdr.sty, line 107

and my code is as follow:

\documentclass[a4paper,twoside]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
% package for including graphics with figure-environment
\usepackage{graphicx}
% package for bibliography
\usepackage{cite}
\usepackage{subcaption}
\usepackage[automark]{scrlayer-scrpage}
\usepackage{float}
\usepackage{fancyhdr}
\usepackage{listings}
\usepackage{comment}
\usepackage{afterpage}
\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
\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{ }
\begin{center}
\section*{Abstract}
\end{center}
hi, how are you
\newpage
\thispagestyle{plain}
\cleardoublepage
\thispagestyle{fancy}
\cfoot{ }
\begin{center}
\section*{Acknowledgments}
\end{center}
\newpage
\thispagestyle{plain}
\cleardoublepage
\thispagestyle{fancy}
\cfoot{ }
\begin{center}
\section*{Abbreviations}
\end{center}
\newpage
\thispagestyle{empty}
\tableofcontents
\newpage
\thispagestyle{empty}
\listoffigures
\newpage
\thispagestyle{empty}
\listoftables
\newpage

\pagenumbering{arabic}
\setcounter{page}{1}
\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}


Any Help is highly appreciated.

• You are mixing incompatible packages: you are loading both scrlayer-scrpage and fancyhdr (which causes the error) and using macros from both packages. Choose one. – campa Jan 27 at 7:50
• Is there a way to now which macros belongs to which package? so I can eliminate them in my case? – Nano Jan 28 at 6:26

In your case you are trying to use two packages scrlayer-scrpage and fancyhdr. The culprit here is that package scrlayer-scrpage defines and uses for example an command \cfoot. With the call of the second package fancyhdr this package also tries to define and use an own command \cfoot and that is impossible, because that comand is already defined and in use ...

So your solution is to use only scrlayer-scrpage (I would recommed it if you are using the class scrartcl or scrreprt or scrbook). Because you are using class article I recommend to use package fancyhdr.

So please have a closer look to the following MWE where I commented all your wrong used commands and added some new commands marked with comments like % <======= with or without explanation ...

Now you have an consistent numbering of your pages, page numbers are shown where they are needed and are not shown on your titlepage ...

\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}
\usepackage{subcaption}
%\usepackage[automark]{scrlayer-scrpage} % <============================
\usepackage{float}
\usepackage{fancyhdr}
\usepackage{listings}
\usepackage{comment}
\usepackage{afterpage}
%\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
\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{ }
\begin{center}
\section*{Abstract}
\end{center}
hi, how are you
\newpage
%   \thispagestyle{plain}
\cleardoublepage
%   \thispagestyle{fancy}
%   \cfoot{ }
\begin{center}
\section*{Acknowledgments}
\end{center}
\newpage
%   \thispagestyle{plain}
\cleardoublepage
%   \thispagestyle{fancy}
%   \cfoot{ }
\begin{center}
\section*{Abbreviations}
\end{center}
\newpage
%   \thispagestyle{empty}
\tableofcontents
\newpage
%   \thispagestyle{empty}
\listoffigures
\newpage
%   \thispagestyle{empty}
\listoftables
\newpage

\pagenumbering{arabic}
\pagestyle{fancy} % <===================================================
%\setcounter{page}{1} % <===============================================
\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}


and the resultinhg title page

and the resulting table of content

BTW: Content and all your section headings are formated to be left justifing, only your abstract until abbreviations headings are formated to be centered. That looks not pretty, use the same format for all headings!

• I can't be more thankful to you. I have never seen such a detailed answer. Thank you for your time and efforts. – Nano Jan 29 at 9:32