6

Here is my minimal working example. I have a .bib file given by

@article{example,
    author  =   {Author},
    title   =   {Title},
    journal =   {Journal},
    year    =   {2018},
    url     =   {\href{https://arxiv.org/abs/1606.08794}{arXiv:1606.08794}}
}

and a .tex file

\documentclass{article}

\usepackage[backend=biber,style=alphabetic]{biblatex}
\usepackage{hyperref}
\addbibresource{biblio.bib}
\renewbibmacro{in:}{} % cosmetical

\begin{document}
    I want to cite \cite{example}.

    \printbibliography
\end{document}

The outputted bibliography has the single entry

[Aut18] Author, "Title". Journal (2018). URL: %5Cref%7Bhttps://arxiv.org/abs/1606.08794%7D%7BarXiv:1606.08794%7D

Instead of the desired

[Aut18] Author, "Title". Journal (2018). URL: arXiv:1606.08794

I see what happens, and I understand more or less what the problem is, but I don't know how to solve it. Does anyone know how to make it work?

Note 1: If I just put url = {https://arxiv.org/abs/1606.08794}, then I get the full url as a hyperlink in the bibliography, but I would really like it to be in shortened form.

Note 2: I took one random article in my bibliography for the link.

3
  • 2
    arXiv preprints are given in the eprint field: eprint = {1606.08794}, eprinttype = {arxiv} (maybe also eprintclass = {math.AT}). The URL field is always read verbatim and must be fed a URL, no markup is allowed. If you don't want to see the URL as entered in the URL field you must use a different field.
    – moewe
    Commented Jan 24, 2018 at 9:29
  • @moewe Ok, thanks. If you put your comment as answer, I will accept it. Commented Jan 24, 2018 at 9:38
  • How would you answer the question if it was not a defined format like arxiv? I think the problem with \DeclareFieldFormat is that it can only take one variable. So if I try \DeclareFieldFormat{url}{\href{#1}{#2}} and then url = {\href{google.com}{MyTxt}} It fails... Any thoughts? Commented Aug 11, 2023 at 17:34

1 Answer 1

9

The url field is read verbatim and must always be a bare URL only. You don't need to escape any special characters and you cannot use any markup commands.

If you wish for a different format of the URL field, you must modify the field format via \DeclareFieldFormat. This is not necessary here, since biblatex has a native way of dealing with arXiv preprints. You can use eprint

eprint      = {1606.08794},
eprinttype  = {arxiv},

maybe also

eprintclass = {math.AT},

You must log in to answer this question.

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