plk / biblatex

biblatex is a sophisticated bibliography system for LaTeX users. It has considerably more features than traditional bibtex and supports UTF-8
517 stars 118 forks source link

Error: Command \cite already defined. #1343

Closed davidzanger closed 8 months ago

davidzanger commented 8 months ago

When I try to execute the following simple latex script:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{comment}

\usepackage[
backend=biber,
style=alphabetic,
sorting=ynt
]{biblatex}
\addbibresource{sample.bib}

\title{Bibliography management: \texttt{biblatex} package}
\author{Overleaf}
\date{ }

\begin{document}

\maketitle

Using \texttt{biblatex} you can display bibliography divided into sections, 
depending of citation type. 
Let's cite! The Einstein's journal paper \cite{einstein} and the Dirac's 
book \cite{dirac} are physics related items. 

\printbibliography

\end{document}

Using the following sample.bib file:

@article{einstein,
    author =       "Albert Einstein",
    title =        "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
    [{On} the electrodynamics of moving bodies]",
    journal =      "Annalen der Physik",
    volume =       "322",
    number =       "10",
    pages =        "891--921",
    year =         "1905",
    DOI =          "http://dx.doi.org/10.1002/andp.19053221004  [Add to Citavi project by DOI] ",
    keywords =     "physics"
}

@book{dirac,
    title={The Principles of Quantum Mechanics},
    author={Paul Adrien Maurice Dirac},
    isbn={9780198520115  [Add to Citavi project by ISBN] },
    series={International series of monographs on physics},
    year={1981},
    publisher={Clarendon Press},
    keywords = {physics}
}

I get the error: Command \cite already defined. Any idea what could cause this error? I get the following log:

main.log This is pdfTeX, Version 3.141592653-2.6-1.40.25 (MiKTeX 24.1) (preloaded format=pdflatex 2024.2.8) 19 FEB 2024 13:07 entering extended mode restricted \write18 enabled. file:line:error style messages enabled. %&-line parsing enabled. **c:/Users/user/Documents/programming/trial_document/main.tex (c:/Users/user/Documents/programming/trial_document/main.tex LaTeX2e <2023-11-01> patch level 1 L3 programming layer <2024-01-22> (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\article.cls Document Class: article 2023/05/17 v1.4n Standard LaTeX document class (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\size10.clo File: size10.clo 2023/05/17 v1.4n Standard LaTeX file (size option) ) \c@part=\count187 \c@section=\count188 \c@subsection=\count189 \c@subsubsection=\count190 \c@paragraph=\count191 \c@subparagraph=\count192 \c@figure=\count193 \c@table=\count194 \abovecaptionskip=\skip48 \belowcaptionskip=\skip49 \bibindent=\dimen140 ) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\inputenc.sty Package: inputenc 2021/02/14 v1.3d Input encoding file \inpenc@prehook=\toks17 \inpenc@posthook=\toks18 ) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/babel\babel.sty Package: babel 2024/01/07 v24.1 The Babel package \babel@savecnt=\count195 \U@D=\dimen141 \l@unhyphenated=\language79 (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/babel\txtbabel.def) \bbl@readstream=\read2 \bbl@dirlevel=\count196 ************************************* * Local config file bblopts.cfg used * (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/arabi\bblopts.cfg File: bblopts.cfg 2005/09/08 v0.1 add Arabic and Farsi to "declared" options of babel ) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/babel-english\english.ldf Language: english 2017/06/06 v3.3r English support from the babel system Package babel Info: Hyphen rules for 'canadian' set to \l@english (babel) (\language0). Reported on input line 102. Package babel Info: Hyphen rules for 'australian' set to \l@ukenglish (babel) (\language73). Reported on input line 105. Package babel Info: Hyphen rules for 'newzealand' set to \l@ukenglish (babel) (\language73). Reported on input line 108. )) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/babel/locale/en\babel-english.tex Package babel Info: Importing font and identification data for english (babel) from babel-en.ini. Reported on input line 11. ) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/comment\comment.sty \CommentStream=\write3 Excluding comment 'comment') (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/biblatex\biblatex.sty Package: biblatex 2023/03/05 v3.19 programmable bibliographies (PK/MW) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/pdftexcmds\pdftexcmds.sty Package: pdftexcmds 2020-06-27 v0.33 Utility functions of pdfTeX for LuaTeX (HO) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/infwarerr\infwarerr.sty Package: infwarerr 2019/12/03 v1.5 Providing info/warning/error messages (HO) ) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/iftex\iftex.sty Package: iftex 2022/02/03 v1.0f TeX engine tests ) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/ltxcmds\ltxcmds.sty Package: ltxcmds 2023-12-04 v1.26 LaTeX kernel commands for general use (HO) ) Package pdftexcmds Info: \pdf@primitive is available. Package pdftexcmds Info: \pdf@ifprimitive is available. Package pdftexcmds Info: \pdfdraftmode found. ) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/etoolbox\etoolbox.sty Package: etoolbox 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW) \etb@tempcnta=\count197 ) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/graphics\keyval.sty Package: keyval 2022/05/29 v1.15 key=value parser (DPC) \KV@toks@=\toks19 ) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/kvoptions\kvoptions.sty Package: kvoptions 2022-06-15 v3.15 Key value format for package options (HO) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/kvsetkeys\kvsetkeys.sty Package: kvsetkeys 2022-10-05 v1.19 Key value parser (HO) )) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/logreq\logreq.sty Package: logreq 2010/08/04 v1.0 xml request logger \lrq@indent=\count198 (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/logreq\logreq.def File: logreq.def 2010/08/04 v1.0 logreq spec v1.0 )) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\ifthen.sty Package: ifthen 2022/04/13 v1.1d Standard LaTeX ifthen package (DPC) ) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/url\url.sty \Urlmuskip=\muskip16 Package: url 2013/09/16 ver 3.4 Verb mode for urls, etc. ) \c@tabx@nest=\count199 \c@listtotal=\count266 \c@listcount=\count267 \c@liststart=\count268 \c@liststop=\count269 \c@citecount=\count270 \c@citetotal=\count271 \c@multicitecount=\count272 \c@multicitetotal=\count273 \c@instcount=\count274 \c@maxnames=\count275 \c@minnames=\count276 \c@maxitems=\count277 \c@minitems=\count278 \c@citecounter=\count279 \c@maxcitecounter=\count280 \c@savedcitecounter=\count281 \c@uniquelist=\count282 \c@uniquename=\count283 \c@refsection=\count284 \c@refsegment=\count285 \c@maxextratitle=\count286 \c@maxextratitleyear=\count287 \c@maxextraname=\count288 \c@maxextradate=\count289 \c@maxextraalpha=\count290 \c@abbrvpenalty=\count291 \c@highnamepenalty=\count292 \c@lownamepenalty=\count293 \c@maxparens=\count294 \c@parenlevel=\count295 \blx@tempcnta=\count296 \blx@tempcntb=\count297 \blx@tempcntc=\count298 \c@blx@maxsection=\count299 \blx@maxsegment@0=\count300 \blx@notetype=\count301 \blx@parenlevel@text=\count302 \blx@parenlevel@foot=\count303 \blx@sectionciteorder@0=\count304 \blx@sectionciteorderinternal@0=\count305 \blx@entrysetcounter=\count306 \blx@biblioinstance=\count307 \labelnumberwidth=\skip50 \labelalphawidth=\skip51 \biblabelsep=\skip52 \bibitemsep=\skip53 \bibnamesep=\skip54 \bibinitsep=\skip55 \bibparsep=\skip56 \bibhang=\skip57 \blx@bcfin=\read3 \blx@bcfout=\write4 \blx@langwohyphens=\language80 \c@mincomprange=\count308 \c@maxcomprange=\count309 \c@mincompwidth=\count310 Package biblatex Info: Trying to load biblatex default data model... Package biblatex Info: ... file 'blx-dm.def' found. (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/biblatex\blx-dm.def File: blx-dm.def 2023/03/05 v3.19 biblatex localization (PK/MW) ) Package biblatex Info: Trying to load biblatex style data model... Package biblatex Info: ... file 'alphabetic.dbx' not found. Package biblatex Info: Trying to load biblatex custom data model... Package biblatex Info: ... file 'biblatex-dm.cfg' not found. \c@afterword=\count311 \c@savedafterword=\count312 \c@annotator=\count313 \c@savedannotator=\count314 \c@author=\count315 \c@savedauthor=\count316 \c@bookauthor=\count317 \c@savedbookauthor=\count318 \c@commentator=\count319 \c@savedcommentator=\count320 \c@editor=\count321 \c@savededitor=\count322 \c@editora=\count323 \c@savededitora=\count324 \c@editorb=\count325 \c@savededitorb=\count326 \c@editorc=\count327 \c@savededitorc=\count328 \c@foreword=\count329 \c@savedforeword=\count330 \c@holder=\count331 \c@savedholder=\count332 \c@introduction=\count333 \c@savedintroduction=\count334 \c@namea=\count335 \c@savednamea=\count336 \c@nameb=\count337 \c@savednameb=\count338 \c@namec=\count339 \c@savednamec=\count340 \c@translator=\count341 \c@savedtranslator=\count342 \c@shortauthor=\count343 \c@savedshortauthor=\count344 \c@shorteditor=\count345 \c@savedshorteditor=\count346 \c@labelname=\count347 \c@savedlabelname=\count348 \c@institution=\count349 \c@savedinstitution=\count350 \c@lista=\count351 \c@savedlista=\count352 \c@listb=\count353 \c@savedlistb=\count354 \c@listc=\count355 \c@savedlistc=\count356 \c@listd=\count357 \c@savedlistd=\count358 \c@liste=\count359 \c@savedliste=\count360 \c@listf=\count361 \c@savedlistf=\count362 \c@location=\count363 \c@savedlocation=\count364 \c@organization=\count365 \c@savedorganization=\count366 \c@origlocation=\count367 \c@savedoriglocation=\count368 \c@origpublisher=\count369 \c@savedorigpublisher=\count370 \c@publisher=\count371 \c@savedpublisher=\count372 \c@language=\count373 \c@savedlanguage=\count374 \c@origlanguage=\count375 \c@savedoriglanguage=\count376 \c@pageref=\count377 \c@savedpageref=\count378 \shorthandwidth=\skip58 \shortjournalwidth=\skip59 \shortserieswidth=\skip60 \shorttitlewidth=\skip61 \shortauthorwidth=\skip62 \shorteditorwidth=\skip63 \locallabelnumberwidth=\skip64 \locallabelalphawidth=\skip65 \localshorthandwidth=\skip66 \localshortjournalwidth=\skip67 \localshortserieswidth=\skip68 \localshorttitlewidth=\skip69 \localshortauthorwidth=\skip70 \localshorteditorwidth=\skip71 Package biblatex Info: Trying to load compatibility code... Package biblatex Info: ... file 'blx-compat.def' found. (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/biblatex\blx-compat.def File: blx-compat.def 2023/03/05 v3.19 biblatex compatibility (PK/MW) ) Package biblatex Info: Trying to load generic definitions... Package biblatex Info: ... file 'biblatex.def' found. (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/biblatex\biblatex.def File: biblatex.def 2023/03/05 v3.19 biblatex compatibility (PK/MW) \c@textcitecount=\count379 \c@textcitetotal=\count380 \c@textcitemaxnames=\count381 \c@biburlbigbreakpenalty=\count382 \c@biburlbreakpenalty=\count383 \c@biburlnumpenalty=\count384 \c@biburlucpenalty=\count385 \c@biburllcpenalty=\count386 \biburlbigskip=\muskip17 \biburlnumskip=\muskip18 \biburlucskip=\muskip19 \biburllcskip=\muskip20 \c@smartand=\count387 C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/biblatex\biblatex.def:2353: LaTeX Error: Command \cite already defined. Or name \end... illegal, see p.192 of the manual. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ... l.2353 \newrobustcmd*{\cite}{\bibsentence\cite} Your command was ignored. Type I to replace it with another command, or to continue without it. C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/biblatex\biblatex.def:2354: LaTeX Error: Command \cites already defined. Or name \end... illegal, see p.192 of the manual. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ... l.2354 \newrobustcmd*{\cites}{\bibsentence\cites} Your command was ignored. Type I to replace it with another command, or to continue without it. ) Package biblatex Info: Trying to load bibliography style 'alphabetic'... Package biblatex Info: ... file 'alphabetic.bbx' found. (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/biblatex/bbx\alphabetic.bbx File: alphabetic.bbx 2023/03/05 v3.19 biblatex bibliography style (PK/MW) Package biblatex Info: Trying to load bibliography style 'standard'... Package biblatex Info: ... file 'standard.bbx' found. (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/biblatex/bbx\standard.bbx File: standard.bbx 2023/03/05 v3.19 biblatex bibliography style (PK/MW) \c@bbx:relatedcount=\count388 \c@bbx:relatedtotal=\count389 )) Package biblatex Info: Trying to load citation style 'alphabetic'... Package biblatex Info: ... file 'alphabetic.cbx' found. (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/biblatex/cbx\alphabetic.cbx File: alphabetic.cbx 2023/03/05 v3.19 biblatex citation style (PK/MW) Package biblatex Info: Redefining '\cite'. Package biblatex Info: Redefining '\parencite'. Package biblatex Info: Redefining '\footcite'. Package biblatex Info: Redefining '\footcitetext'. Package biblatex Info: Redefining '\smartcite'. Package biblatex Info: Redefining '\textcite'. Package biblatex Info: Redefining '\textcites'. Package biblatex Info: Redefining '\cites'. Package biblatex Info: Redefining '\parencites'. Package biblatex Info: Redefining '\smartcites'. ) Package biblatex Info: Trying to load configuration file... Package biblatex Info: ... file 'biblatex.cfg' found. (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/biblatex\biblatex.cfg File: biblatex.cfg ) Package biblatex Info: Input encoding 'utf8' detected. Package biblatex Info: Document encoding is UTF8 .... (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/l3kernel\expl3.sty Package: expl3 2024-01-22 L3 programming layer (loader) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/l3backend\l3backend-pdftex.def File: l3backend-pdftex.def 2024-01-04 L3 backend support: PDF output (pdfTeX) \l__color_backend_stack_int=\count390 \l__pdf_internal_box=\box51 )) Package biblatex Info: ... and expl3 (biblatex) 2024-01-22 L3 programming layer (loader) (biblatex) is new enough (at least 2020/04/06), (biblatex) setting 'casechanger=expl3'. (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/biblatex\blx-case-expl3.sty (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/l3packages/xparse\xparse.sty Package: xparse 2023-10-10 L3 Experimental document command parser ) Package: blx-case-expl3 2023/03/05 v3.19 expl3 case changing code for biblatex )) Package biblatex Warning: 'babel/polyglossia' detected but 'csquotes' missing. (biblatex) Loading 'csquotes' recommended. \@quotelevel=\count391 \@quotereset=\count392 (c:\Users\user\Documents\programming\trial_document\build\main.aux) \openout1 = `main.aux'. LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 18. LaTeX Font Info: ... okay on input line 18. LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 18. LaTeX Font Info: ... okay on input line 18. LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 18. LaTeX Font Info: ... okay on input line 18. LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 18. LaTeX Font Info: ... okay on input line 18. LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 18. LaTeX Font Info: ... okay on input line 18. LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 18. LaTeX Font Info: ... okay on input line 18. LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 18. LaTeX Font Info: ... okay on input line 18. Package biblatex Info: Trying to load language 'english'... Package biblatex Info: ... file 'english.lbx' found. (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/biblatex/lbx\english.lbx File: english.lbx 2023/03/05 v3.19 biblatex localization (PK/MW) ) Package biblatex Info: Input encoding 'utf8' detected. Package biblatex Info: Automatic encoding selection. (biblatex) Assuming data encoding 'utf8'. \openout4 = `main.bcf'. Package biblatex Info: Trying to load bibliographic data... Package biblatex Info: ... file 'main.bbl' found. (c:\Users\user\Documents\programming\trial_document\build\main.bbl) Package biblatex Info: Reference section=0 on input line 18. Package biblatex Info: Reference segment=0 on input line 18. LaTeX Font Info: External font `cmex10' loaded for size (Font) <12> on input line 20. LaTeX Font Info: External font `cmex10' loaded for size (Font) <8> on input line 20. LaTeX Font Info: External font `cmex10' loaded for size (Font) <6> on input line 20. LaTeX Font Info: External font `cmex10' loaded for size (Font) <7> on input line 27. LaTeX Font Info: External font `cmex10' loaded for size (Font) <5> on input line 27. [1 {C:/Users/user/AppData/Local/MiKTeX/fonts/map/pdftex/pdftex.map}] (c:\Users\user\Documents\programming\trial_document\build\main.aux) *********** LaTeX2e <2023-11-01> patch level 1 L3 programming layer <2024-01-22> *********** LaTeX Warning: There were undefined references. Package biblatex Warning: Please rerun LaTeX. Package logreq Info: Writing requests to 'main.run.xml'. \openout1 = `main.run.xml'. ) Here is how much of TeX's memory you used: 9692 strings out of 474541 190984 string characters out of 5743482 1926978 words of memory out of 5000000 31871 multiletter control sequences out of 15000+600000 562693 words of font info for 52 fonts, out of 8000000 for 9000 1141 hyphenation exceptions out of 8191 66i,6n,81p,731b,1738s stack positions out of 10000i,1000n,20000p,200000b,200000s Output written on c:\Users\user\Documents\programming\trial_document\build\main.pdf (1 page, 99394 bytes). PDF statistics: 46 PDF objects out of 1000 (max. 8388607) 0 named destinations out of 1000 (max. 500000) 1 words of extra memory for PDF output out of 10000 (max. 10000000)
hvoss49 commented 8 months ago

no problem here with up-to-date TeXLive 2023. What is the contents of your local file bblopts.cfg?

[...]
Local config file bblopts.cfg used
(C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/arabi\bblopts.cfg
File: bblopts.cfg 2005/09/08 v0.1 add Arabic and Farsi to "declared" options of babel
) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/babel-english\english.ldf
davidzanger commented 8 months ago

This is the content of the bblopts.cfg file:

% \iffalse meta-comment
%
% Copyright 2006      Youssef Jabri
% 
% 
% This file is part of the `Arabi' system.
% -------------------------------------------
% 
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3b
% of this license or (at your option) any later version.
% The latest version of this license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.3b or later is part of all distributions of LaTeX 
% version 2005/12/01 or later.
% 
% This file has the LPPL maintenance status "maintained".
% 
% 
% \fi
%
% Filename: bblopts.cfg
%
% 
%
%

\ProvidesFile{bblopts.cfg}
        [2005/09/08 v0.1 %
          add Arabic and Farsi to "declared" options of babel]

\DeclareOption{arabic}{%
  \input{arabic.ldf}
  }

\DeclareOption{farsi}{%
  \input{farsi.ldf}
  }

\endinput
hvoss49 commented 8 months ago

I See, nothing special. But I am wondering why this file is loaded because your example document has nothing to do with arabic? Put \listfiles as first line into the document and send your file list (at the end of the log file)

moewew commented 8 months ago

There is two weird things going on in the .log file. It says

C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/biblatex\biblatex.def:2353: LaTeX Error: Command \cite already defined.
Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
...

l.2353 \newrobustcmd*{\cite}{\bibsentence\cite}

But in biblatex v3.19 line 2353 of biblatex.def is not \newrobustcmd*{\cite}{\bibsentence\cite}. There is \newrobustcmd*{\Cite}{\bibsentence\cite}, which won't error because it defines \Cite with a capital "C", in line 2299. (Line 2353 is \newrobustcmd*{\Autocite}{\bibsentence\autocite}, which likewise won't error.)

It looks as though your biblatex.def isn't the correct one. It also looks as though maybe someone lowercased all of its contents, so that the line \newrobustcmd*{\Cite}{\bibsentence\cite}, which is correct, became \newrobustcmd*{\cite}{\bibsentence\cite}, which is completely wrong.

Did you or anyone else modify files installed by MikTeX?

Maybe it already helps to uninstall and reinstall the biblatex package in the MikTeX Console?

josephwright commented 8 months ago

@moewew Cases like this is why for the next LaTeX release we've added MD5 hashes to \listfiles (\listfiles[hashes]) - available in the dev release but probably not ready for the prime time just yet.

davidzanger commented 8 months ago

@moewew You are right. I reinstalled the package and now it works. I assume it happened when I replaced all \autocite commands with \cite commands. Probably, the file was open during the replacement.

Thanks to all who helped!