2

I'm building on this template using Biblatex/biber for managing my references and for citation. To better indicate which references I co-authored, I want them to use a slightly different cite style than references to others' work. For example, the generated text should look like this:

In my previous work [My1] and [My14], I investigated impact of factors A and B. Factor C was recently evaluated by Others et al. [1] and Someone and Else [3].

So basically, my citations should have a custom prefix, here "My", and separate numbering from the others citations (which have another prefix, here nothing "").

All references should be printed in the bibliography at the end of the document. For better overview, the two different categories may be listed separately, i.e., first my publications with keys [My1]-[My23] and then others' publications with keys [1]-[211].

Is that possible somehow easily? I think I'd have to use bibliography categories somehow; but I don't know exactly how.

2
  • Are you going to list your works in a separate bibliography? If not, how would your entries sort compared to other entries? As always, it would be great if you could include a short example document of what you have so far along with about four example entries, so we can test our ideas with your setup.
    – moewe
    Commented Feb 4, 2021 at 7:42
  • Thanks for the questions. Yes, I'd want to have the bibliography split into two parts, first listing my works and then the works of others. But if there's another sensible way to do this, I'm also fine with it. I'm building on a quite complex template and am unsure how to extract the relevant parts for a MWE, but linked it in the updated description. Do Biblatex categories go into the right direction here? Do they provide the option of adding a prefix to citation keys? Commented Feb 4, 2021 at 8:01

1 Answer 1

1

I guess the most user friendly solution here is one where biblatex can automatically tell which works are yours and which are not. This can be done with the code from Filter bibliography by author?. (If you don't mind adding entries to categories manually, things are of course a bit simpler.)

Then it is just a matter of starting a new refcontext with labelprefix for your works and asking biblatex to reset the numbering for the other works. Throw in defernumbers because we have split numeric bibliographies and you are good to go.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[backend=biber,style=numeric, defernumbers]{biblatex}
\usepackage{hyperref}

\addbibresource{biblatex-examples.bib}

\makeatletter
\def\fnblx@bibfile@name{\jobname -fnblx.bib}
\newwrite\fnblx@bibfile
\immediate\openout\fnblx@bibfile=\fnblx@bibfile@name

\immediate\write\fnblx@bibfile{%
  @comment{Auto-generated file}\blx@nl}

\newcounter{fnblx@name}
\setcounter{fnblx@name}{0}

\newcommand*{\fnblx@writenametobib}[1]{%
  \stepcounter{fnblx@name}%
  \edef\fnblx@tmp@nocite{%
    \noexpand\AfterPreamble{%
      \noexpand\setbox0\noexpand\vbox{%
        \noexpand\fnblx@getmethehash{fnblx@name@\the\value{fnblx@name}}}}%
  }%
  \fnblx@tmp@nocite
  \immediate\write\fnblx@bibfile{%
    @misc{fnblx@name@\the\value{fnblx@name}, author = {\unexpanded{#1}}, %
          options = {dataonly=true},}%
  }%
}

\AtEndDocument{%
  \closeout\fnblx@bibfile}

\addbibresource{\fnblx@bibfile@name}

\newcommand*{\fnblx@namehashes}{}
\DeclareNameFormat{fnblx@hashextract}{%
  \xifinlist{\thefield{hash}}{\fnblx@namehashes}
    {}
    {\listxadd{\fnblx@namehashes}{\thefield{hash}}}}

\DeclareCiteCommand{\fnblx@getmethehash}
  {}
  {\printnames[fnblx@hashextract][1-999]{author}}
  {}
  {}

\newtoggle{fnblx@tempa}
\DeclareIndexNameFormat{fnblx@checkfilternames}{%
  \xifinlist{\thefield{hash}}{\fnblx@namehashes}
    {\global\toggletrue{fnblx@tempa}}
    {}}

\newcommand*{\addbfilternames}{\forcsvlist\fnblx@writenametobib}
\newcommand*{\resetfilternames}{\def\fnblx@namehashes{}}

\defbibcheck{filternames}{%
  \global\togglefalse{fnblx@tempa}
  \indexnames[fnblx@checkfilternames][1-999]{labelname}%
  \iftoggle{fnblx@tempa}
    {}
    {\skipentry}}
    
\defbibcheck{notfilternames}{%
  \global\togglefalse{fnblx@tempa}
  \indexnames[fnblx@checkfilternames][1-999]{labelname}%
  \iftoggle{fnblx@tempa}
    {\skipentry}
    {}}
\makeatother

\addbfilternames{Emma Sigfridsson}

\begin{document}
Lorem \autocite{sigfridsson}
ipsum \autocite{worman}
dolor \autocite{geer}
sit \autocite{knuth:ct:a,knuth:ct:b}

\begin{refcontext}[labelprefix=My]
\printbibliography[check=filternames, title={Works by Emma Sigfridsson}]
\end{refcontext}
\printbibliography[resetnumbers, check=notfilternames, title={Works not by Emma Sigfridsson}]
\end{document}

Lorem [My1] ipsum [4] dolor [1] sit [2, 3]


For comparison here is the same document with categories where you have to specify manually which entries are yours

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[backend=biber,style=numeric, defernumbers]{biblatex}
\usepackage{hyperref}

\addbibresource{biblatex-examples.bib}

\DeclareBibliographyCategory{mywork}
\addtocategory{mywork}{sigfridsson}

\begin{document}
Lorem \autocite{sigfridsson}
ipsum \autocite{worman}
dolor \autocite{geer}
sit \autocite{knuth:ct:a,knuth:ct:b}

\begin{refcontext}[labelprefix=My]
\printbibliography[category=mywork, title={Works by Emma Sigfridsson}]
\end{refcontext}
\printbibliography[resetnumbers, notcategory=mywork, title={Works not by Emma Sigfridsson}]
\end{document}
3
  • Thanks! It almost does what I want, but I can't completely reproduce your example. I only have limited own work, so I don't mind adding that to a category manually, i.e., following your instructions in the end. Unfortunately, my work is now only cited always using the key [My] - not followed by any number; so it's impossible to distinguish different references to my own work. Any idea what could be the problem? I usually use \cite{} but also tested \autocite{} and it doesn't seem to make a difference. Commented Feb 5, 2021 at 9:10
  • Without changing a thing, just by citing more of my papers and building a couple more times, it works as it should! Strange. But problem solved. Commented Feb 5, 2021 at 10:26
  • 1
    @CGFoX The option defernumbers needs at least two LaTeX runs after a successful Biber run to properly assign the numbers. If you play around with some options it sometimes happens that the numbering gets stuck in an incorrect state. In that case it helps to delete the .aux, .bbl and .bcf files and recompile.
    – moewe
    Commented Feb 5, 2021 at 12:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .