3

I've currently got the following options in biblatex:

\usepackage[
backend = biber,
%   style = authoryear, (default style is numeric)
    sorting = nyt,
    sortcites = true,
    defernumbers=true,
    date = edtf,
    urldate = edtf,
    seconds=true,
    maxcitenames = 1,
    maxbibnames = 100,
    backref = true
] {biblatex}

When I type \textcite{key}, I get a citation style that looks like this:

First_Author_Name et al. [#]

Is there an easy way--without changing to the authoryear style--to get to the following style:

First_Author_Name et al., (Year) [#]

Sorry if this question has been asked before. I've looked through previous questions and couldn't find anything of this sort.

moewe
  • 175,683
mjbeyeler
  • 209

1 Answers1

5

Not that I would recommend it. As discussed in the comments this style is redundant and very unusual - which is OK if you aim for that sort of thing, but maybe not as advisable otherwise. I can see the appeal of having the author and year mentioned in the citation label since it allows the reader to judge the history of certain things. But then the number is just added weight that serves no additional purpose, since author-year citations - if done correctly - are enough to identify the source uniquely.

The code is not as simple as it could be, because textcite has a tricky implementation with a touch of -comp going on, but here you go

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

\usepackage[style=numeric, labeldateparts, backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}

\makeatletter
\renewbibmacro*{textcite:init}{%
  \ifnumless{\value{multicitecount}}{2}
    {\global\boolfalse{cbx:parens}}
    {}%
  \global\undef\cbx@lasthash
  \global\undef\cbx@lastyear}

\renewbibmacro*{textcite}{%
   \ifboolexpr{test {\iffieldequals{namehash}{\cbx@lasthash}}
               and test {\iffieldequals{labelyear}{\cbx@lastyear}}}
    {\setunit{\multicitedelim}}
    {\ifnameundef{labelname}
       {\printfield[citetitle]{labeltitle}}
       {\printnames{labelname}}%
     \setunit*{\printdelim{nameyeardelim}}%
     \printlabeldate
     \setunit{\printdelim{namelabeldelim}}%
     \printtext{\bibopenbracket}\global\booltrue{cbx:parens}%
     \stepcounter{textcitecount}}%
  \savefield{namehash}{\cbx@lasthash}%
  \savefield{labelyear}{\cbx@lastyear}%
  \ifnumequal{\value{citecount}}{1}
    {\usebibmacro{prenote}}
    {}%
  \usebibmacro{cite}%
  \setunit{%
    \ifbool{cbx:parens}
      {\bibclosebracket\global\boolfalse{cbx:parens}}
      {}%
    \textcitedelim}}

\DeclareCiteCommand{\textcite}[\cbx@textcite@init\cbx@textcite]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{textcite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \ifboolexpr{test {\iffieldequals{namehash}{\cbx@lasthash}}
               and test {\iffieldequals{labelyear}{\cbx@lastyear}}}
     {}
     {\stepcounter{textcitetotal}}%
   \savefield{namehash}{\cbx@lasthash}%
   \savefield{labelyear}{\cbx@lastyear}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\makeatother

\begin{document}
\textcite{sigfridsson}

\textcite{knuth:ct:a,knuth:ct:b}

\textcite{knuth:ct:b,knuth:ct:c}

\printbibliography
\end{document}

enter image description here

Essentially this is a copy of numeric.cbx's tetxcite definition. But where the original only tests for the name we test for name and year. And naturally we additionally also print the year where the original would only print the name.

moewe
  • 175,683
  • Thanks, I'll look into it. If textcite is a bad option, what would you suggest using instead to get the same result? The thing is, I'd like to maintain a numbered bibliography. I also have an additional implementation that allows me to click on the citation number and directly be forwarded to the corresponding bibliography entry. – mjbeyeler Jun 17 '18 at 16:35
  • 1
    @Michael It is not that \textcite is bad. It's just that an author-year-numeric label is neither here nor there. A numeric label on its own or author-year would be enough to identify the citation uniquely. Putting both together adds nothing and just makes the label artificially longer. – moewe Jun 17 '18 at 16:38
  • Ah, I see. Well, my first basic idea was to go with the numeric style because it is more intuitive to then click on the number to be forwarded to the bibliography entry. But, thinking about it some more, it's actually useful sometimes while reading to know the year a referenced study was published in (without having to go to the bibliography). So I wanted to keep both. But I guess I could also go with the authoryear style, and have people click on the year to be forwarded to the bibliography. – mjbeyeler Jun 17 '18 at 16:41
  • @Michael I'd just go with the predominant style in your discipline. As you say links can be applied to all biblatex styles, so that should not be an issue. Inventing your own style may seem like a good idea but can lead to hybrid styles that just look weird and confuse people. – moewe Jun 17 '18 at 16:48
  • That sounds very reasonable. I'm just in an early experimental phase, but I guess in the end I'll go with the "Author et al., Year" style. That's the predominant style. It's a bit of a tangent, but you wouldn't happen to know how to change hyperref options so that I can click on the cited author, and not only the year? – mjbeyeler Jun 17 '18 at 17:01
  • 3
    @Michael Have a look at https://tex.stackexchange.com/q/15951/35864 and the millions of linked questions there. Full linking is not entirely easy (conceptually and implementation wise), so is not enabled by default. – moewe Jun 17 '18 at 17:04