1

Is it possible to change from

"A et al., 2014; 2016; B et al., 2014"

to

 "A et al., 2014 & 2016; B et al., 2014"

I suspect:

\usepackage[backend=biber, 
% style=authoryear, 
 style=authoryear-comp,
% citestyle=authoryear, 
dashed=false,
maxcitenames=2,
maxbibnames=99,
uniquelist=false, 
giveninits,
alldates=comp, 
dateabbrev=false,
uniquename=false,backref=true,backrefstyle=none]{biblatex}

enter image description here

The output I want is:

​(Hands et al., 2014 & 2016; Mudariki et al., 2014)

My MWE:

\documentclass{article}
\usepackage{xpatch}
% \usepackage[style = authoryear-comp, maxnames = 99]{biblatex}

\usepackage[backend=biber, 
% style=authoryear, 
 style=authoryear-comp,
% citestyle=authoryear, 
dashed=false,
maxcitenames=2,
maxbibnames=99,
uniquelist=false, 
giveninits,
alldates=comp, 
dateabbrev=false,
uniquename=false,backref=true,backrefstyle=none]{biblatex}


% to make volume (number), eg. 4(2)
\newcommand*{\volnumdelim}{}
\DeclareFieldFormat[article,periodical]{number}{\mkbibparens{#1}}

\renewbibmacro*{volume+number+eid}{%
  \printfield{volume}%
  \setunit*{\volnumdelim}%
  \printfield{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}}

\newcommand*{\jourvoldelim}{\addcomma\space}
\newcommand*{\jourserdelim}{\newunitpunct}
\newcommand*{\servoldelim}{\jourvoldelim}
\newcommand*{\volnumdatedelim}{\addspace}

\renewbibmacro*{journal+issuetitle}{%
  \usebibmacro{journal}%
  \setunit*{\jourvoldelim}%
  \iffieldundef{series}
    {}
    {\setunit*{\jourserdelim}%
     \printfield{series}%
     \setunit{\servoldelim}}%
  \usebibmacro{volume+number+eid}%
  \setunit{\volnumdatedelim}%
  \usebibmacro{issue+date}%
  \setunit{\addcolon\space}%
  \usebibmacro{issue}%
  \newunit}  
% to make volume (number), eg. 4(2)
\DeclareNameAlias{sortname}{family-given} %for second and third author name
\DeclareFieldFormat{postnote}{\printtext[bibhyperref]{#1}}

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

\usepackage[english]{babel}
\usepackage{csquotes}



\addto\captionsenglish{
\renewcommand{\listfigurename}{\textsf{List of Figures}}
\renewcommand{\listtablename}{\textsf{List of Tables}}
}

% Flag for whether to add front matter to TOC
\newtoggle{fulltoc}
\toggletrue{fulltoc}  % Change to \togglefalse{fulltoc} to remove front matter
\renewcommand{\contentsname}{Table of Contents}


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


% for a chapter edited by a book
\usepackage{xpatch}
% \renewcommand*{\finalnamedelim}{\addspace\&\space} 
% \renewcommand*{\intitlepunct}{\space} (to become In:)
\renewcommand{\labelnamepunct}{\space} %to delete . after (1997)
% \DeclareFieldFormat[article, incollection, unpublished]{pages}{#1} % to add in PP. (page)
\DeclareFieldFormat[article, incollection, unpublished]{title}{#1}
% \renewcommand{\bibpagespunct}{\ifentrytype{article}{\addcolon}{\addperiod\addspace}} %cancel out this in order to add in PP. (page)


% for title italic
% \DeclareFieldFormat*{title}{\mkbibemph{#1}} %for title italic in all format (conference, paper..)
\DeclareFieldFormat*{title}{#1} %for conference title delete ".."
\DeclareFieldFormat[incollection]{title}{\mkbibemph{#1}} %for incollecion title italic ONLY
\DeclareFieldFormat[thesis]{title}{\mkbibemph{#1}} %for phdthesis title italic ONLY
% for title italic

% to delete "In:" for article
\renewbibmacro{in:}{%
  \ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
% to delete "In:" for article


% for delete comma after Author A and Aurhor b
\DefineBibliographyExtras{english}{%
   \let\finalandcomma\empty
   \let\finalandsemicolon\empty
 }
\renewcommand{\compcitedelim}{\space\&\space}
\DeclareNameAlias{editorin}{given-family}

\newbibmacro*{byeditor:in}{%
  \ifnameundef{editor}
    {}
    {\printnames[editorin]{editor}%
     \setunit{\addcomma\space}%
     \usebibmacro{editorstrg}%
     \clearname{editor}}}     


\DeclareDelimFormat[textcite]{postnotedelim}{\addcolon\space}
\DeclareDelimFormat[parencite]{postnotedelim}{\addcolon\space}

% \DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{postnote}{\printtext[bibhyperref]{#1}}
\DeclareFieldFormat{multipostnote}{#1}


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

\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]
  {\renewcommand*{\postnotedelim}{\addcolon\space}%
   \usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\cbx@textcite}
  {\renewcommand*{\postnotedelim}{\addsemicolon\space}%
   \usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}}
  {}
  {\usebibmacro{textcite: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)





\DeclareFieldFormat{url}{Available at\addcolon\space\url{#1}}
\DeclareFieldFormat{urldate}{\mkbibbrackets{\bibstring{urlseen}\space#1}}
\DeclareFieldFormat[online]{title}{\mkbibemph{#1}}
\DefineBibliographyStrings{english}{%
  urlseen = {Accessed},
}

\DefineBibliographyExtras{english}{%
  \protected\def\mkdaterangecomp{%
    \mkdaterangetrunc{long}}%
  \protected\def\mkdaterangeterse{%
    \mkdaterangetrunc{short}}%
  \protected\def\mkdaterangecompextra{%
    \mkdaterangetruncextra{long}}%
  \protected\def\mkdaterangeterseextra{%
    \mkdaterangetruncextra{short}}%
  \protected\def\mkbibdatelong#1#2#3{%
    \iffieldundef{#3}
      {}
      {\thefield{#3}%
       \iffieldundef{#2}{}{\nobreakspace}}%
    \iffieldundef{#2}
      {}
      {\mkbibmonth{\thefield{#2}}%
       \iffieldundef{#1}{}{\space}}%
    \iffieldbibstring{#1}
      {\bibstring{\thefield{#1}}}
      {\dateeraprintpre{#1}\stripzeros{\thefield{#1}}}}%
}





\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}



@article{hands2014attenuated,
  title={Title 1},
  author={Hands, James R and Dorling, Konrad M and Abel, Peter and Ashton, Katherine M and Brodbelt, Andrew and Davis, Charles and Dawson, Timothy and Jenkinson, Michael D and Lea, Robert W and Walker, Carol and others},
  journal={Journal of biophotonics},
  volume={7},
  number={3-4},
  pages={189--199},
  year={2014},
  publisher={Wiley Online Library}
}

@article{hands2016brain,
  title={Title 2},
  author={Hands, James R and Clemens, Graeme and Stables, Ryan and Ashton, Katherine and Brodbelt, Andrew and Davis, Charles and Dawson, Timothy P and Jenkinson, Michael D and Lea, Robert W and Walker, Carol and others},
  journal={Journal of neuro-oncology},
  volume={127},
  number={3},
  pages={463--472},
  year={2016},
  publisher={Springer}
}

@article{mudariki2014p59diagnostic,
  title={Title 3},
  author={Mudariki, T and Lea, RW and Clemens, G and Baker, MJ},
  journal={Neuro-oncology},
  volume={16},
  number={Suppl 6},
  pages={vi10},
  year={2014},
  publisher={Oxford University Press}
}



\end{filecontents*}

\addbibresource{\jobname.bib}

\begin{document}
\nocite{WinNT}

The sample ABC is done by \parencite{hands2014attenuated, mudariki2014p59diagnostic, hands2016brain} in a way.


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

1 Answers1

2

biblatex inserts \compcitedelim between the years in a -comp citation. We can redefine that command to insert an ampersand.

So normally the following should work

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear-comp, backend=biber]{biblatex}

\renewcommand*{\compcitedelim}{\addspace\&\space}

\addbibresource{biblatex-examples.bib}

\begin{document}
Lorem \parencite{sigfridsson,knuth:ct:a,knuth:ct:b}
\printbibliography
\end{document}

Lorem (Knuth 1984 & 1986; Sigfridsson and Ryde 1998)

See also this earlier question of yours: How to put a both year together in referencing. Eg. Smith (1992 & 1993)?.


But in your code you already redefine \compcitedelim and the outcome is not as desired. That is due to your redefinition of \parencite to obtain full linking. Simply adding \printtext[bibhyperref] around \usebibmacro{cite} confuses the punctuation tracker and causes wrong punctuation marks to show up.

Remove

\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\renewcommand*{\postnotedelim}{\addcolon\space}%
   \usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\cbx@textcite}
  {\renewcommand*{\postnotedelim}{\addsemicolon\space}%
   \usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}}
  {}
  {\usebibmacro{textcite:postnote}}  



\makeatletter
\let\abx@macro@textciteOrig\abx@macro@textcite
\renewbibmacro{textcite}{% <============================================
   \bibhyperref{%
   \let\bibhyperref\relax\relax%
   \abx@macro@textciteOrig%
   }%
}%
\makeatother

and replace it with

\DeclareDelimFormat[parencite,textcite]{postnotedelim}{\addcolon\space}

This will change the postnote punctuation to a colon for \parencite and \etxtcite. If you want it changed for all citation commands, you only need

\DeclareDelimFormat{postnotedelim}{\addcolon\space}

Since most of this code was intended to get the a fuller hyperlinking of the citation commands, this will of course remove the name linking from \parencite. If you absolutely need to have it back, you'll need to put in some additional work. You need to redefine the cite macros.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear-comp, backend=biber]{biblatex}
\usepackage[colorlinks, citecolor=blue]{hyperref}

\renewcommand*{\compcitedelim}{\addspace\&\space}

\makeatletter
\renewbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\printtext[bibhyperref]{%
          \usebibmacro{cite:label}%
          \setunit{\printdelim{nonameyeardelim}}%
          \usebibmacro{cite:labeldate+extradate}}%
        \usebibmacro{cite:reinit}}
       {\iffieldequals{namehash}{\cbx@lasthash}
          {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                       \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
             {\setunit{\addcomma}%
              \printtext[bibhyperref]{\usebibmacro{cite:extradate}}}
             {\setunit{\compcitedelim}%
              \printtext[bibhyperref]{\usebibmacro{cite:labeldate+extradate}}%
              \savefield{labelyear}{\cbx@lastyear}}}
          {\printtext[bibhyperref]{%
             \printnames{labelname}%
             \setunit{\printdelim{nameyeardelim}}%
             \usebibmacro{cite:labeldate+extradate}}%
           \savefield{namehash}{\cbx@lasthash}%
           \savefield{labelyear}{\cbx@lastyear}}}}
    {\usebibmacro{cite:shorthand}%
     \usebibmacro{cite:reinit}}%
  \setunit{\multicitedelim}}

\newbibmacro*{citeyear}{%
  \iffieldundef{shorthand}
    {\iffieldundef{labelyear}
       {\printtext[bibhyperref]{\usebibmacro{cite:label}}%
        \usebibmacro{cite:reinit}}
       {\iffieldequals{namehash}{\cbx@lasthash}
          {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                       \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
             {\setunit{\addcomma}%
              \printtext[bibhyperref]{\usebibmacro{cite:extradate}}}
             {\setunit{\compcitedelim}%
              \printtext[bibhyperref]{\usebibmacro{cite:labeldate+extradate}}%
              \savefield{labelyear}{\cbx@lastyear}}}
          {\printtext[bibhyperref]{\usebibmacro{cite:labeldate+extradate}}%
           \savefield{namehash}{\cbx@lasthash}%
           \savefield{labelyear}{\cbx@lastyear}}}}
    {\usebibmacro{cite:shorthand}%
     \usebibmacro{cite:reinit}}%
  \setunit{\multicitedelim}}

\renewbibmacro*{textcite}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\iffieldundef{shorthand}
       {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                    \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
          {\setunit{\addcomma}%
           \printtext[bibhyperref]{\usebibmacro{cite:extradate}}}
          {\setunit{\compcitedelim}%
           \printtext[bibhyperref]{\usebibmacro{cite:labeldate+extradate}}%
           \savefield{labelyear}{\cbx@lastyear}}}
       {\setunit{\compcitedelim}%
        \printtext[bibhyperref]{\usebibmacro{cite:shorthand}}%
        \global\undef\cbx@lastyear}}
    {\ifnameundef{labelname}
       {\iffieldundef{shorthand}
          {\printtext[bibhyperref]{\usebibmacro{cite:label}}%
           \setunit{%
             \global\booltrue{cbx:parens}%
             \printdelim{nonameyeardelim}\bibopenparen}%
           \ifnumequal{\value{citecount}}{1}
             {\usebibmacro{prenote}}
             {}%
           \printtext[bibhyperref]{\usebibmacro{cite:labeldate+extradate}}}
          {\printtext[bibhyperref]{\usebibmacro{cite:shorthand}}}}
       {\printtext[bibhyperref]{\printnames{labelname}}%
        \setunit{%
          \global\booltrue{cbx:parens}%
          \printdelim{nameyeardelim}\bibopenparen}%
        \ifnumequal{\value{citecount}}{1}
          {\usebibmacro{prenote}}
          {}%
        \iffieldundef{shorthand}
          {\iffieldundef{labelyear}
             {\printtext[bibhyperref]{\usebibmacro{cite:label}}}
             {\printtext[bibhyperref]{\usebibmacro{cite:labeldate+extradate}}}%
           \savefield{labelyear}{\cbx@lastyear}}
          {\printtext[bibhyperref]{\usebibmacro{cite:shorthand}}%
           \global\undef\cbx@lastyear}}%
     \stepcounter{textcitecount}%
     \savefield{namehash}{\cbx@lasthash}}%
  \setunit{%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}%
    \textcitedelim}}

\newbibmacro*{cite:shorthand}{%
  \printfield{shorthand}}

\newbibmacro*{cite:label}{%
  \iffieldundef{label}
    {\printfield[citetitle]{labeltitle}}
    {\printfield{label}}}

\renewbibmacro*{cite:labeldate+extradate}{%
  \printlabeldateextra}

\renewbibmacro*{cite:extradate}{%
  \printfield{extradate}}
\makeatother

\DeclareDelimFormat{postnotedelim}{\addcolon\space}

\addbibresource{biblatex-examples.bib}

\begin{document}
Lorem \parencite{sigfridsson,knuth:ct:a,knuth:ct:b}

\Textcite{sigfridsson,knuth:ct:a,knuth:ct:b} ipsum

\printbibliography
\end{document}

Lorem (Knuth 1984 & 1986; Sigfridsson and Ryde 1998)

moewe
  • 175,683
  • thanks. you are brillant! Can I ask one more question: Why when I compile it came to be Lorem (Knuth A 1996 & 1984), suppose to be Lorem (Knuth A 1984 & 1996) where earlier year come first. I suspect is because my references is is arrange in alphabetical order a..b to z in order. Can I force year in order? I can post a new question if you need. – aan May 27 '20 at 12:05
  • @aan Please ask a new question about that. At the moment I don't quite understand what is happening. – moewe May 27 '20 at 14:06
  • thanks. Posted a new questions here https://tex.stackexchange.com/questions/546522/how-to-have-the-citing-order-in-years-but-citing-references-is-according-to-alp. Let me know if my question is not clear – aan May 27 '20 at 15:06
  • thanks. I am unable to cross-referencing for author name using this \citeauthor{sigfridsson}'s studies \autocite*{sigfridsson}. Is there any other method? – aan May 27 '20 at 15:32