TransWikia.com

My cite command doesn't work: how to fix that?

TeX - LaTeX Asked by domi on April 12, 2021

My cite{} command doesn’t seem to work as expected while my bibliographical references are correctly set. How could I fix that? Could you please tell me if I didn’t forget something anywhere? This is my MWE:

    documentclass[a4paper,12pt,twoside]{book}
    usepackage{mathptmx}
    setcounter{secnumdepth}{3}
    setcounter{tocdepth}{3}
    usepackage{setspace}
    usepackage[left=4.5cm,right=4.5cm,top=5cm,bottom=5cm]{geometry}
    onehalfspacing
    usepackage[frenchb]{babel}
    usepackage[T1]{fontenc}
    usepackage[utf8]{inputenc}
    usepackage{tocloft}
    renewcommand{cftchapleader}{cftdotfill{cftdotsep}} % for chapters
    usepackage[numberedbib,nosectionbib]{apacite}
    usepackage[makeindex]{imakeidx}
    makeindex[name=npr, title=Index des noms cités] 
    makeindex[name=mat, title=Index des matières]
    begin{filecontents}{mybib.bib}
@book{Tufte2002,
 author = {Tufte, Blabla},
 year = {2002},
 title = {A title},
 
}
end{filecontents}
    
    usepackage{hyperref}
    begin{document}
    title{A title}
    
    maketitle
    
    
    renewcommand{contentsname}{Table}
    tableofcontents
    
    chapter{A title}
    
    cite{Tufte2002}
    
    bibnewpage 
    {%start grouping
      doublespacing % <====================================================
      raggedright 
      nocite{}
      bibliographystyle{apacite} 
        bibliography{mybib}
    }%end grouping
    
    phantomsection
    cleardoublepage
    printindex[npr] 
    addcontentsline{toc}{chapter}{Index des noms cités}
    printindex[mat]
    addcontentsline{toc}{chapter}{Index des matières}
    
    end{document}

One Answer

Further reducing the MWE results in the following example code that upon compiling twice results in the following error message:

documentclass{book}

usepackage[numberedbib,nosectionbib]{apacite}
usepackage{hyperref}

begin{filecontents}{mybib.bib}
@book{Tufte2002,
 author = {Tufte, Blabla},
 year = {2002},
 title = {A title},
 
}
end{filecontents}
    
begin{document}
    
cite{Tufte2002}

bibliographystyle{apacite} 
bibliography{mybib} 

end{document}

Undefined control sequence.
hyper@@link ->let Hy@reserved@a 
                                   relax @ifnextchar [{hyper@link@ }{hyp...
l.17 cite{Tufte2002}

This can be solved by inverting the load order of apacite and hyperref, loading apacite after hyperref.

This is also mentioned in the apacite manual:

The hyperref package turns (cross-) references into hypertext links. This can beused in conjunction with a program such as LATEX2HTML to compose .html files with clickable links, to internet pages or within the same document, or it can be used to create a .pdf document with clickable crossreferences. Evidently, citations are also references. Therefore, the hyperref package transforms these into hypertext links as well, and needs to redefine the citation commands and reference list commands in order to do so. These redefinitions have caused severe incompatibility problems between apacite and hyperref in the past. These incompatibility problems have been solved and apacite is compatible with hyperref, provided that apacite is loaded after hyperref.

Answered by leandriis on April 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP