I have a special field in my bibliography, called adsurl, and I would like to display this url in my file as a link.
However, when I try this, href throws a very weird error. It enters some sort of infinite loop where it keeps saying
! Undefined control sequence.
\filename@simple ...#2\\}\fi \edef \filename@base
{#1}
MWE:
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@online{elk,
author = {Anne Elk},
title = {On the Theory of Brontosauruses},
adsurl = {https://example.edu/~elk/bronto.html},
}
\end{filecontents*}
\usepackage[hyperref,backend=biber]{biblatex}
\usepackage{hyperref}
\addbibresource{\jobname.bib}
\begin{filecontents*}{biblatex-dm.cfg}
\DeclareDatamodelFields[type=field, datatype=literal, skipout=false]{adsurl}
\DeclareDatamodelEntryfields{adsurl}
\end{filecontents*}
\begin{document}
\cite{elk} %this works
\citefield{elk}{adsurl} %this also works
\href{\citefield{elk}{adsurl}}{ads} %this does not work
\end{document}
How can I get href to accept the output of citefield as url?
\citefielddoes a bit more than just 'returning' the value of the field, so it can't be used as argument to\href. – moewe May 04 '18 at 15:42DeclareFieldFormatwith abibhyperrefdirective get the job done here? – gusbrs May 04 '18 at 15:46\DeclareFieldFormat{adsurl}{\href{#1}{ads}}? That would be a viable option if the link text is fixed. The\citefieldgets a bit more awkward, though, since we have to specify the format (otherwise\citefielddefaults to thecitefieldformat):\citefield{elk}[adsurl]{adsurl}. If the 'ads' text ought to be variable, one would have to find a way to inject the correct text into the format (probably via a wrapper command). In that case a new\DeclareCiteCommandwith postnote seems nicer to me. – moewe May 04 '18 at 15:50adsurlis similar to the arXiv you could also check out theeprintfield. – moewe May 07 '18 at 11:44adsurlandeprintare different things and are usually both defined – fifaltra May 07 '18 at 15:24