1

I am asking almost the same question as link for similar questions

I want to have

Smith (1998 & 1999)

However, for this question, i added

style=authoryear-comp. 

and

\renewcommand{\compcitedelim}{\space\&\space} 

to my MWE, is not working

It might be because of

citestyle=authoryear

enter image description here

\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}

@article{journal1,
  title={title ABC},
  author={Smith, Bether},
  journal={Behavior Research Methods, Instruments, \& Computers},
  volume={24},
  number={2},
  pages={258--264},
  year={1992},
  publisher={Springer}
}

@article{journal2,
  title={title CBD},
  author={Smith, Bether},
  journal={Behavior Research Methods, Instruments, \& Computers},
  volume={25},
  number={2},
  pages={242--249},
  year={1993},
  publisher={Springer}
}


@article{journal2,
  title={journal123456},
  author={Abc, Def, GhI},
  journal={Journal of Neurology, Neurosurgery \& Psychiatry},
  volume={62},
  number={1},
  pages={22--26},
  year={1999},
}


\end{filecontents}


\documentclass[british]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}

\usepackage{csquotes}
\usepackage[%
  style=authoryear, 
  style=authoryear-comp, 
  backend=biber, 
  maxcitenames=2,
  giveninits,
 dashed=false,
  citestyle=authoryear,
]{biblatex}
\addbibresource{\jobname.bib} % \jobname to use the bib file created with filecontents

\usepackage[unicode,colorlinks,citecolor=blue]{hyperref}

\DeclareNameAlias{sortname}{family-given} %for second and third author name



% for references 's studies (year)
\renewcommand*{\nameyeardelim}{\addcomma\space}
\newcommand{\mycite}[1]{\citeauthor{#1}'s \citeyear{#1}}

% for combine both year for an author
\DeclareDelimFormat{nameyeardelim}{\addcomma\space}
\renewcommand{\compcitedelim}{\space\&\space}

\DeclareCiteCommand{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printtext[bibhyperref]{\printnames{labelname}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\citeyear} % <======================================
    {}
    {(\bibhyperref{\printdate})}
    {\multicitedelim}
    {}

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


\makeatletter
\let\abx@macro@textciteOrig\abx@macro@textcite
\renewbibmacro{textcite}{% <============================================
   \bibhyperref{%
   \let\bibhyperref\relax\relax%
   \abx@macro@textciteOrig%
   }%
}%
\makeatother
% for references 's studies (year)

\begin{document}



ABC studies is done by \textcite{journal1, journal2}.

\printbibliography
\end{document}
aan
  • 2,663

1 Answers1

2

This is because you have two style options and end with the citestyle option in your biblatex set up.

style sets both citestyle and bibstyle.

Remove them all and just leave style=authoryear-comp:

\usepackage[%
  style=authoryear-comp, 
  maxcitenames=2,
  giveninits,
  dashed=false,
]{biblatex}

Also, backend=biber is the default and not needed.

Using authoryear-comp also means you have to slightly change your redefinition of \parencite:

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

I also suspect your attempt to get the name to be a hyperlink with \textcite is going to cause you problems. Apart from the fact that the closing bracket isn't hyperlinked, which bibliography entry should the name point to? In this case it only makes sense to link the years. (Although, I guess it kind of works like you have it.)

David Purton
  • 25,884
  • Thanks. If I remove citestyle=authoryear, the \parencite{} is not working. It need citestyle=authoryear – aan Sep 13 '19 at 00:41
  • @aan, that's because of other customisations you have made. I'll track down the problem. – David Purton Sep 13 '19 at 00:45
  • @aan, you're missing \usebibmacro{cite:init} from your redefinition of \parencite. Look in authoryear-comp.cbx for the default definition. – David Purton Sep 13 '19 at 00:53
  • thanks. it worked in my MWE. However, when I tried all the same setting in my real Overleaf thesis writing, it appears to be Smith (1998), 1999) which is wrong. – aan Sep 13 '19 at 01:51
  • 1
    @aan, Either you have other customisations in your actual thesis that are breaking things. Or this is because the version of biblatex on overleaf is too old. I don't know which. You'll have to work backwards, cutting out customisations one by one until you know where the problem is. – David Purton Sep 13 '19 at 01:57
  • thanks. I did try compare one by one, quite headache and maybe miss some line. Anyway, where to check my version of biblatex ? – aan Sep 13 '19 at 01:59
  • Do you have an up to date local TeX install? What happens if you build your thesis on that? The latest version of biblatex is 3.13. You can add \listfiles at the top of any document and the log file will show you the version in use. – David Purton Sep 13 '19 at 02:02
  • If your MWE (with my two changes) works on Overleaf, then the problem must be in other customisations in your thesis. – David Purton Sep 13 '19 at 02:04
  • Thanks. I edited two changes (redefination parencite, style) I posted this question in https://tex.stackexchange.com/questions/508112/i-had-customisations-my-biblatex-result-is-smith-1992-1993-it-suppose-sm – aan Sep 13 '19 at 02:20
  • One TeXnical (and not conceptual) problem of the \parencite definition that you rightly point out as problematic is discussed in https://tex.stackexchange.com/q/546403/35864. The \printtext in that position completely confuses the punctuation buffer. – moewe May 27 '20 at 06:19