Add eprint to unpublished bibliography items

biblatexbibliographies

I have a research article which is accepted (and has title, journal and doi, but no date or issue yet). A preprint is available. I'd like to have an item in my biblatex-bibliography that reflects this. I'm using standard numeric style at the moment. I'd think of something like

Bubaya. “Some smart paper.” To appear in: Exclusive journal. DOI: ... Preprint: arXiv:...,

but I am flexible. I think you got the idea. What I don't like so far is messing with related articles, but maybe I just didn't do it right.

How do I achieve something like this?

A similar question was asked already (biblatex & references: unpublished style with eprint), but gave no satisfactory answer.

Edit: Would the downvoter mind explaining what disturbs them, such that I can change my question? Arguably, the following looks really bad:

\documentclass{article}
\usepackage{biblatex,hyperref}
\begin{filecontents}[overwrite]{bib.bib}
    @article{entry,
        author = "W. Crawley-Boevey",
        title = "Decomposition of pointwise finite-dimensional persistence modules",
        journal = "Journal of Algebra and Its Applications",
        volumne = "14",
        number = "5",
        year = "2015",
        pubstate = "forthcoming",
        doi = "10.1142/S0219498815500668",
        eprint = "1210.0819",
        eprinttype = "arxiv",
    }
\end{filecontents}
\addbibresource{bib.bib}
\nocite{*}
\begin{document}
    \printbibliography
\end{document}

Best Answer

You can modify the macros that print the involved fields as follow, testing the pubstate:

\documentclass{article}
\usepackage{biblatex,hyperref}
\begin{filecontents}[overwrite]{bib.bib}
    @article{entry,
        author = "W. Crawley-Boevey",
        title = "Decomposition of pointwise finite-dimensional persistence modules",
        journal = "Journal of Algebra and Its Applications",
        volume = "14",
        number = "5",
        year = "2015",
        pubstate = "forthcoming",
        doi = "10.1142/S0219498815500668",
        eprint = "1210.0819",
        eprinttype = "arxiv",
    }
    @article{arta,
        author = "A. Author",
        title = "An ordinary article",
        journal = "An ordinary journal",
        volume = "15",
        number = "1",
        year = "2016",
        pubstate = "published",
        doi = "10.1234/S0219498815501234",
        eprint = "1234.1234",
        eprinttype = "arxiv",
   }
   @article{artb,
        author = "B. Buthor",
        title = "A second article",
        journal = "A second journal",
        volume = "16",
        number = "3",
        year = "2020",
        doi = "10.7777/S0219498815501234",
        eprint = "1234.7777",
        eprinttype = "arxiv",
   }
   @article{artc,
        author = "C. Cuthor",
        title = "A submitted article",
        journal = "A third journal",
        year = "2023",
        pubstate = "submittedto",
        doi = "10.7777/S0219498815501234",
        eprint = "1234.7777",
        eprinttype = "arxiv",
   }
\end{filecontents}

\addbibresource{bib.bib}

% from https://tex.stackexchange.com/a/408041/101651
\NewBibliographyString{toappearin}
\NewBibliographyString{submittedto}
\NewBibliographyString{preprint}
\DefineBibliographyStrings{english}{%
  toappearin  = {to appear in},
  submittedto = {submitted to},
  preprint = {preprint},
}

\renewbibmacro*{in:}{%
  \ifboolexpr{not test {\iffieldundef{pubstate}}
              and (test {\iffieldequalstr{pubstate}{toappearin}}
                   or test{\iffieldequalstr{pubstate}{submittedto}}
                   or test{\iffieldequalstr{pubstate}{forthcoming}}
                   )}
    {\printtext{\bibstring{toappearin}\intitlepunct}}%
    {\printtext{\bibstring{in}\intitlepunct}}%
    }

% from https://tex.stackexchange.com/q/295080/101651
\makeatletter
\DeclareFieldFormat*{eprint:arxiv}{{% Note the extra brace
  \ifboolexpr{not test {\iffieldundef{pubstate}}
              and (test {\iffieldequalstr{pubstate}{toappearin}}
                   or test{\iffieldequalstr{pubstate}{submittedto}}
                   or test{\iffieldequalstr{pubstate}{forthcoming}}
                   )}
    {\printtext{\bibstring{preprint}\addcolon\addspace arXiv}}%
    {arXiv}%ù
    \addcolon\space
  \ifhyperref
    {\href{http://arxiv.org/\abx@arxivpath/#1}{%
       \nolinkurl{#1}%
       \iffieldundef{eprintclass}
         {}
         {\addspace\texttt{\mkbibbrackets{\thefield{eprintclass}}}}}}
    {\nolinkurl{#1}
     \iffieldundef{eprintclass}
       {}
       {\addspace\texttt{\mkbibbrackets{\thefield{eprintclass}}}}}}}
\makeatother
  
\renewbibmacro*{addendum+pubstate}{%
  \printfield{addendum}}

\nocite{*}

\begin{document}
    \printbibliography
\end{document}

enter image description here