# citefield inside of href [duplicate]

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},
}
\end{filecontents*}

\usepackage[hyperref,backend=biber]{biblatex}
\usepackage{hyperref}

\begin{filecontents*}{biblatex-dm.cfg}
\end{filecontents*}

\begin{document}
\cite{elk} %this works
\end{document}


How can I get href to accept the output of citefield as url?

## marked as duplicate by gusbrs, Phelype Oleinik, Mensch, Troy, Stefan PinnowMay 7 '18 at 11:40

• Does tex.stackexchange.com/q/412924/35864 help? \citefield does a bit more than just 'returning' the value of the field, so it can't be used as argument to \href. – moewe May 4 '18 at 15:42
• More relevant: tex.stackexchange.com/q/413365/35864 – moewe May 4 '18 at 15:45
• @moewe, wouldn't a DeclareFieldFormat with a bibhyperref directive get the job done here? – gusbrs May 4 '18 at 15:46
• @gusbrs You mean \DeclareFieldFormat{adsurl}{\href{#1}{ads}}? That would be a viable option if the link text is fixed. The \citefield gets a bit more awkward, though, since we have to specify the format (otherwise \citefield defaults to the citefield format): \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 \DeclareCiteCommand with postnote seems nicer to me. – moewe May 4 '18 at 15:50
• The question remains searchable even if closed as a duplicate. It only just occurred to me: If the adsurl is similar to the arXiv you could also check out the eprint field. – moewe May 7 '18 at 11:44

Thanks to the links provided by moewe, I was able to fix this. So I decided to answer this so people won't have to click through to the other questions.

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@online{elk,
author       = {Anne Elk},
title        = {On the Theory of Brontosauruses},
}
\end{filecontents*}

\usepackage[hyperref,backend=biber]{biblatex}
\usepackage{hyperref}

\begin{filecontents*}{biblatex-dm.cfg}
\end{filecontents*}

%Here's the trick:
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}