[Tex/LaTex] Latex error: Command \citename already defined. …*{\citename}{\blx@citexpunct{citename}}

biblatexcompilation errorcompiling

I am try to compile my Latex file but I am getting this error during compilation:

Update Error message:

! LaTeX Error: Command \citename already defined.
Or name \end... illegal, see p.192 of the manual.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.10472 ...*{\citename}{\blx@citexpunct{citename}}
Your command was ignored.

This is my Latex file definitions:

\begin{filecontents*}{example.eps}
\end{filecontents*}
\RequirePackage{fix-cm}
\documentclass{svjour3}  
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\usepackage[euler]{textgreek}
\usepackage{harvard}
\usepackage{empheq}
\usepackage{amsmath}
\DeclareMathOperator{\rank}{rank}
\makeatletter
\newenvironment{sqcases}{%
\matrix@check\sqcases\env@sqcases
 }{%
\endarray\right.%
 }
\def\env@sqcases{%
\let\@ifnextchar\new@ifnextchar
\left\lbrack
\def\arraystretch{1.2}%
\array{@{}l@{\quad}l@{}}%
}
\makeatletter
\def\BState{\State\hskip-\ALG@thistlm}
\algnewcommand\algorithmicforeach{\textbf{for each}}
\algdef{S}[FOR]{ForEach}[1]{\algorithmicforeach\ #1\ \algorithmicdo}

\makeatother

\usepackage[utf8]{inputenc}
\usepackage[style=authoryear-comp, citetracker=true, maxcitenames=1, 
giveninits, terseinits, uniquename=init]{biblatex}
\AtEveryCitekey{\ifciteseen{}{\defcounter{maxnames}{2}}}

\usepackage{filecontents}

   \begin{filecontents}{\jobname.bib}
    @article{lam2016nonparametric,
        title={Nonparametric eigenvalue-regularized precision or covariance 
         matrix estimator},
         author={Lam, Clifford},
         journal={The Annals of Statistics},
         volume={44},
         number={3},
         pages={928--953},
         year={2016},
    publisher={Institute of Mathematical Statistics},
    doi = {0.1214/15-AOS1393}
    }

   \end{filecontents}

  \addbibresource{\jobname.bib}
  \addbibresource{biblatex-examples.bib}

  \DeclareNameAlias{sortname}{family-given}
  \renewcommand*{\revsdnamepunct}{}
  \DeclareDelimAlias{finalnamedelim}{multinamedelim}

  \DeclareDelimFormat[bib,biblist]{nametitledelim}{\addspace}

  \DeclareFieldFormat*{title}{#1}
  \DeclareFieldFormat*{journaltitle}{#1}
  \DeclareFieldFormat*{booktitle}{#1}
  \DeclareFieldFormat*{maintitle}{#1}

  \renewbibmacro{in:}{%
  \ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}

  \renewbibmacro*{publisher+location+date}{%
  \printlist{publisher}%
  \setunit*{\addcomma\space}%
  \printlist{location}%
  \setunit*{\addcomma\space}%
  \usebibmacro{date}%
  \newunit}

  \renewcommand*{\bibpagespunct}{\ifentrytype{article}{\addcolon} 
  {\addcomma\space}}
  \DeclareFieldFormat[article,periodical]{pages}{#1}

  \DeclareFieldFormat{doi}{\url{https://doi.org/#1}}

  \DeclareSourcemap{
    \maps[datatype=bibtex]{
        \map{
        \pertype{article}
        \step[fieldset=number, null]
    }
    }
    }

  \renewcommand*{\finentrypunct}{}
  \begin{document}
  .
  .
  .
  .
  \printbibliography
  \end{document}

Any idea about how can I fix this error ?

Best Answer

You are loading harvard and latter biblatex. harvard is meant to work on a BibTeX setting for bibliography/citation, not with biblatex.

The problem you face with this particular error is that harvard has already defined \citename when you load biblatex which tries to define the same macro. So you get an error out of it.

In sum, if you intend to use biblatex, you should leave out \usepackage{harvard}.

Related Question