plk / biblatex

biblatex is a sophisticated bibliography system for LaTeX users. It has considerably more features than traditional bibtex and supports UTF-8
507 stars 115 forks source link

Add relations for preprints #835

Open denismaier opened 5 years ago

denismaier commented 5 years ago

It is getting more and more common that journal articles are available also as preprints. When citing a preprint article we might also want to give the publication details of the published version, or we might also want to indicate where a (free) preprint can be found when we cite the published version (possibly behind a paywall). Is adding a relationship for this an option? Perhaps preprintof and preprintat.

moewew commented 5 years ago

Do you have a concrete idea of what the output would look like for such a relation? Are you thinking about the related functionality or are you referring to a more general 'relationship'? I guess at the moment people mainly use the eprint or url fields and don't explicitly mention whether the linked version is a pre-print; or they just let their reader find these preprint versions themselves and don't link them.

denismaier commented 5 years ago

Well, actually the output produced by reprintas and reprintof is not so bad:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{bib.bib}
@online{doe,
author = "Doe, John",
title = "Important article",
year = "2018",
url = "www.webserver.com/article.pdf",
related = "doe-published",
relatedtype = "reprintas",
relatedstring = "Published version:",
}

@article{doe-published,
author = "Doe, John",
title = "Important article",
year = "2018",
journaltitle = "Important Journal",
volume = "20",
pages = "87-112",
}

@article{doe2,
author = "Doe, John",
title = "Another important article",
year = "2018",
journaltitle = "Important Journal",
volume = "20",
pages = "200-250",
related = "doe2-orig",
relatedtype = "reprintof",
relatedstring = "Pages numbers follow the Open-Access version:",
}

@online{doe2-orig,
author = "Doe, John",
title = "Important article",
year = "2018",
url = "www.webserver.com/article.pdf",
}
\end{filecontents}
\usepackage[style=verbose]{biblatex}
\addbibresource{bib.bib}

\begin{document}
Hi.\footcite{doe} Hi again.\footcite{doe2}
\printbibliography
\end{document}

This gives us:

Doe, John. "Another important article". In: Important Journal 20 (2018), pp. 200-250. Pages numbers follow the Open-Access version: Important article. 2018. url: www.webserver.com/article.pdf.

Important article. 2018. url: www.webserver.com/article.pdf. Published version: "Important article". In: Important Journal 20 (2018), pp. 87-112.

I find it somewhat disturbing that the title appears twice. In the case of the reprintof relation I think I could use the addendum for a note like that. The result would be: Doe, John. "Another important article". In: Important Journal 20 (2018), pp. 200-250. Pages numbers follow the Open-Access version available at www.webserver.com/article.pdf.

In the second case (reprintas) it would not be that easy. The output should look like this: Important article. 2018. url: www.webserver.com/article.pdf. Published version in: Important Journal 20 (2018), pp. 87-112.

moewew commented 4 years ago

Here is a slightly modified version of related:default (which is what both reprintas and reprintof in the previous code example use) that also suppresses the title if they are the same between the parent and related entry. (I don't want to suppress the title if it is not the same as in doe2, because that may make it harder to find the preprint with different title.)

\documentclass{article}

\usepackage[style=verbose]{biblatex}

\newbibmacro*{bbx:related:supprestitle}[1]{%
  \entrydata*{#1}{%
    \usedriver
      {\ifnameundef{savedauthor}
         {\ifnameundef{savededitor}
            {}
            {\ifnamesequal{editor}{savededitor}
               {\clearname{editor}}
               {}}}
         {\ifnamesequal{author}{savedauthor}
            {\clearname{author}}
            {}}%
       % titles are equal if only the title bit is the same,
       % don't test for subtitle and titleaddon for now
       \iffieldsequal{savedtitle}{title}
         {\clearfield{title}%
          \clearfield{subtitle}%
          \clearfield{titleaddon}%
          \renewbibmacro{in:}{}}
         {}%
       \renewbibmacro*{related:init}{}%
       \DeclareNameAlias{sortname}{default}%
       \ifbibmacroundef{date+extradate}
         {}
         {\renewbibmacro*{date+extradate}{}%
          \renewbibmacro*{date}{\printdate}}%
       \renewbibmacro*{pageref}{}}
      {\thefield{entrytype}}}}

\newbibmacro*{related:preprintof}{\usebibmacro{bbx:related:supprestitle}}
\newbibmacro*{related:preprintat}{\usebibmacro{bbx:related:supprestitle}}

\begin{filecontents}{\jobname.bib}
@online{doe,
  author        = {Doe, John},
  title         = {Important article},
  year          = {2018},
  url           = {www.webserver.com/article.pdf},
  related       = {doe-published},
  relatedtype   = {preprintof},
  relatedstring = {Published version:},
}
@article{doe-published,
  author       = {Doe, John},
  title        = {Important article},
  year         = {2018},
  journaltitle = {Important Journal},
  volume       = {20},
  pages        = {87-112},
}
@article{doe2,
  author        = {Doe, John},
  title         = {Another important article},
  year          = {2018},
  journaltitle  = {Important Journal},
  volume        = {20},
  pages         = {200-250},
  related       = {doe2-orig},
  relatedtype   = {preprintat},
  relatedstring = {Pages numbers follow the Open-Access version:},
}
@online{doe2-orig,
  author = {Doe, John},
  title  = {Important article},
  year   = {2018},
  url    = {www.webserver.com/article.pdf},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
Hi.\footcite{doe} Hi again.\footcite{doe2}
\printbibliography
\end{document}

It appears to me that you may be more happy with a version of preprintat that only prints the link and nothing else. In which case

\newbibmacro*{related:preprintat}[1]{%
  \entrydata*{#1}{%
    \usebibmacro{doi+eprint+url}}}

may be more appropriate. (Possibly even with a test to clear fields if they are the same as the parent's.)

denismaier commented 4 years ago

Sorry for answering only now...

That looks really good. So what should be done about this now. Does it make sense to add this, or should users take care of this themselves? What do you think?

moewew commented 4 years ago

I think something along those lines might be a useful addition (and it won't impact backwards compatibility). But at the moment the code feels a bit ad-hoc. It is tricky, but would be very desirable, to get something that looks clean and works equally well for most entry types. A lot of things are context depended here. It may for example be desirable to print year and/or title if they differ from the parent entry. Theoretically that seems possible, but the code would get more complex than what I showed above. (The in: detection there is quite flimsy.)