2

I am using biblatex with authoryear-comp for my document. It works fine for authoryear, but authoryear-comp misses citations (or part of) when I recite a cited work. Here is the minimal working example:

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[vietnamese,german,english]{babel}
\selectlanguage{english}
%Bib:
\usepackage[    style=authoryear-comp,
            %natbib=true,
            backend=biber,
            maxcitenames=2,
            firstinits=true,
            maxbibnames=9,
            sorting=nyvt,
            dashed=false,
            eprint=false,
            %numbermonth=false,
            clearlang=true,
            doi=false,
            isbn=false,
            url=false ]{biblatex}
\addbibresource{lab.bib}
\renewbibmacro{in:}{%
\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
%\AtEveryCitekey{\clearfield{month}}
    \AtEveryBibitem{
      \clearfield{edition}
      \clearfield{endday}%
      \clearfield{endmonth}
      \clearfield{month}%
      \clearfield{day}
      \clearfield{language}
      \clearfield{editor}}
\renewcommand\multicitedelim{\addcomma\space}
\renewcommand*{\bibfont}{\small}
%\usepackage{chapterbib}
%\newcommand{\scite}{[\cite{#1}]};

\DeclareCiteCommand{\cite}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{cite}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{citeyear}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\usepackage{etoolbox}
\renewcommand{\bibname}{References}
\defbibheading{secbib}[\bibname]{\section*{#1}}
\defbibheading{subbibliography}[\refname]{\section*{#1}}

\begin{document}

Multiple works~(\cite{Jaynes1957a,Jaynes1957b,Jaynes1988a})

Reciting:~(\cite{Jaynes1957a})

\printbibliography[heading=subbibliography]

\end{document}

with the bib file

@article{Jaynes1957a,
Author = {Jaynes, E T},
Date-Added = {2014-11-13 15:17:17 +0000},
Date-Modified = {2014-11-13 15:17:17 +0000},
Journal = {Phys. Rev.},
Keywords = {information; probability; statistical-mechanics},
Number = {4},
Pages = {620},
Title = {Infomation theory and statistical mechanics {I}},
Volume = {106},
Year = {1957}}

@article{Jaynes1957b,
Author = {Jaynes, E T},
Date-Added = {2014-11-13 15:17:17 +0000},
Date-Modified = {2014-11-13 15:17:17 +0000},
Journal = {Phys. Rev.},
Keywords = {information; probability; statistical-mechanics;},
Pages = {171},
Title = {Information theory and statistical mechanics {II}},
Volume = {108},
Year = {1957}}

@incollection{Jaynes1988a,
Author = {Jaynes, E T},
Booktitle = {Maximum Entropy and Baysian Methods in Science and Engineering},
Date-Added = {2014-11-13 15:17:17 +0000},
Date-Modified = {2014-11-13 15:17:17 +0000},
Editor = {Erickson, G. J. and Smith C. R.},
Keywords = {information; thermodynamics;},
Publisher = {Kluwer Academic Publishers},
Title = {The evolution of Carnot's principle},
Volume = {1},
Year = {1988}}

Here is the output:

Output authoryear-comp

In some other case (my document), things are even worse: nothing appears at the second citation. On the other hand, authoryear works just fine. Can any of you help me with fixing that problem of authoryear-comp? Thank you a lot!

  • The problem is with the way you redefined \cite. What do you want to achieve? – Guido Nov 14 '14 at 5:18
  • @Guido I was trying to remove the square brackets that wrap the citations ([]). – ttuethao Nov 14 '14 at 9:15
  • PS:...and colour the whole citations in hyperlink colour... – ttuethao Nov 14 '14 at 9:36
  • When I comment out your definition of \cite and \cite* I do not get square brackets around citations. – Guido Nov 14 '14 at 10:46
  • Yes, sorry. It was just for colouring the whole citations instead of the year only. – ttuethao Nov 14 '14 at 10:50
1

The problem is that the bibmacro cite saves the hash (unique for each author name) and year of the last used citation in a variable (actually a command). The current definition of \cite does not ensure that the values stored in the variable are cleared. The bibmacro to reset these variable is cite:init. That macro has to be executed for every cite command, thus a modified definition would be:

\DeclareCiteCommand{\cite}
{\usebibmacro{cite:init}\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
 \printtext[bibhyperref]{\usebibmacro{cite}}}
{\multicitedelim}
{\usebibmacro{postnote}}

Alternatively, one could use the current definition and add

\AtEveryCite{\usebibmacro{cite:init}}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.