1

I'm using biblatex for the scientific resources I'm citing. But I also want to add a second list for all online sources that I reference. I have split the bibliography in one file references.bib and one online.bib and I print two bibliographies with:

\printbibliography[heading=bibintoc, nottype=online]
\printbibliography[title={Web References}, type=online]

I use the alphabetic-verb bibliography style which uses keys/labels like [ABD+14], which are the author initials and the date of publication.

The problem is, for the online source I often don't know the authors or the publication date. In the case that I don't have authors I would like to build the key using the first letters of the title.

How can I customize the bibliography key to be build from the title in the case, that no author is specified?

My MWE:

\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{english}
\usepackage{filecontents}
\usepackage[natbib=true,backend=biber,style=alphabetic-verb]{biblatex}

\begin{filecontents}{references.bib}
@Article{a,
  author    = {Some Author and Some Otherauthor and More Of Thiskind and A Longlist},
  title     = {Some Paper Title},
  journal   = {Journal of Papers},
  year      = {2018},
}
@InProceedings{b,
  author    = {Some Author and Some Otherauthor},
  title     = {Some Other Paper Title},
  journal   = {Journal of Papers},
  year      = {2019},
}
\end{filecontents}
\begin{filecontents}{online.bib}
@online{texoverflow,
  title={TeX Stack Exchange},
  shorttitle={TeX},
  urldate={2020-01},
  url={https://tex.stackexchange.com/},
  note   = {\url{https://web.archive.org/web/20200101144309/https://tex.stackexchange.com/}},
}
\end{filecontents}

\addbibresource{references.bib}
\addbibresource{online.bib}

\begin{document}

Two papers \cite{a,b}.

Tex StackExchange is an online community\footnote{Stackoverflow: \cite{texoverflow}}.

\printbibliography[heading=bibintoc, nottype=online]
\printbibliography[title={Web References}, type=online]

\end{document}

Results in:

enter image description here

But I would like to have something like [Tex] as key for the online reference.

Edit I've added an entry with only two authors to also cover this case.

1 Answer 1

2

This is straightforward. The label is controlled by \DeclareLabelalphaTemplate.

The default definition is:

\DeclareLabelalphaTemplate{
  \labelelement{
    \field[final]{shorthand}
    \field{label}
    \field[strwidth=3,strside=left,ifnames=1]{labelname}
    \field[strwidth=1,strside=left]{labelname}
  }
  \labelelement{
    \field[strwidth=2,strside=right]{year}
  }
}

So you could just add shorthand={TeX} to your entry and this would be used as the label.

In the comments @moewe suggests (and you should listen to him) that adding label={TeX} to your entry is the best option. The description of this field from the biblatex manual explains how it works:

A designation to be used by the citation style as a substitute for the regular label if any data required to generate the regular label is missing. For example, when an author-year citation style is generating a citation for an entry which is missing the author or the year, it may fall back to label. See § 2.3.2 for details. Note that, in contrast to shorthand, label is only used as a fallback. See also shorthand.

If you wanted to use the title, then you would need to adjust the definition of \DeclareLabelalphaTemplate slightly. You would have to tell the definition to use the labeltitle field:

\DeclareLabelalphaTemplate{
  \labelelement{
    \field[final]{shorthand}
    \field{label}
    \field[strwidth=3,strside=left,ifnames=1]{labelname}
    \field[strwidth=1,strside=left]{labelname}
    \field{labeltitle}
  }
  \labelelement{
    \field[strwidth=2,strside=right]{year}
  }
}

By default, this will use TeX Stack Exchange as the label, which is a bit long. But if you add a shorttitle field to your entry, then this will be used instead.

Unless you need to keep your bib entries flexible between styles and using the shorthand field would mess things up for you, then simply using shorthand={TeX} is probably the easiest and best option.

MWE

This MWE demonstrates using the title as the label.

\documentclass{article}

\begin{filecontents}[overwrite]{\jobname.bib}
@Article{a,
  author    = {Some Author and Some Otherauthor and More Of Thiskind and A Longlist},
  title     = {Some Paper Title},
  journal   = {Journal of Papers},
  year      = {2018},
}
@online{texoverflow,
  title={TeX Stack Exchange},
  shorttitle={TeX},
  urldate={2020-01},
  url={https://tex.stackexchange.com/},
  note   = {\url{https://web.archive.org/web/20200101144309/https://tex.stackexchange.com/}},
}
\end{filecontents}

\usepackage{polyglossia}
\setmainlanguage{english}

\usepackage[natbib=true,backend=biber,style=alphabetic-verb]{biblatex}
\addbibresource{\jobname.bib}

\DeclareLabelalphaTemplate{
  \labelelement{
    \field[final]{shorthand}
    \field{label}
    \field[strwidth=3,strside=left,ifnames=1]{labelname}
    \field[strwidth=1,strside=left,final]{labelname}
    \field{labeltitle}
  }
  \labelelement{
    \field[strwidth=2,strside=right]{year}
  }
}

\begin{document}

A Paper \cite{a}

Tex StackExchange is an online community\footnote{Stackoverflow: \cite{texoverflow}}.

\printbibliography[heading=bibintoc, nottype=online]
\printbibliography[title={Web References}, type=online]

\end{document}

MWE output

8
  • Thank you for your answer. But there is a problem if one or two authors are specified for an entry. In this case the year is not added. Jan 2, 2020 at 9:10
  • 1
    I think the final in \field[strwidth=1,strside=left,final]{labelname} is not needed and actually causes undesirable behaviour for the case of two names. final terminates the complete label not just the current \labelelement.
    – moewe
    Jan 2, 2020 at 9:39
  • This seams to do the trick. But why does this not print the title in all cases? Jan 2, 2020 at 9:47
  • You may also want to mention the label field. IMHO it is the standard way to provide a replacement label. shorthand always overrides the citation label (which can be unexpected for numeric and authoryear styles), but label is only a fallback in case stuff is missing.
    – moewe
    Jan 2, 2020 at 9:47
  • 1
    @white_gecko The directives in a single \labelelement are executed from top to bottom. The first non-empty output becomes the \labelement and the next \labelelement is processed. If a final element is non-empty, the complete label is terminated. Since the non-@online examples have authors, the first \labelelement consists of the author names.
    – moewe
    Jan 2, 2020 at 9:49

You must log in to answer this question.

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