# add URL to citation apa biblatex

I need to add the URL in the citations in footnotes for every source that has a URL. It should look like the footnotes a and b in the MWE output. I found this: Add URL field to footcites using style=authortitle-icomp but the accepted solution doesn't work for me and I'm not able to modify it to make it work properly (I have commented it in the MWE).

I'm using biblatex, biber, APA style, italian. I edit on Sharelatex.com.

MWE:

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage[babel]{csquotes}
\usepackage[style=apa,backend=biber]{biblatex}
\DeclareLanguageMapping{italian}{italian-apa}

\defbibfilter{online}{
type=online
}

\defbibfilter{offline}{
type=book or
type=article or
type=report
}

%\renewbibmacro*{cite:title}{%
%\printtext[bibhyperref]{\printfield[citetitle]{labeltitle}
%\iffieldundef{url}{}{\nametitledelim\printfield{url}}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}

@online{cit1,
title = {Title},
url = {http://www.website.com},
timestamp = {2013-04-11T17:20:44Z},
urldate = {2013-04-10},
date = {2004}
}

@report{cit2,
author = {BBBAuthor, Name},
title = {Title Title Title},
url = {http://www.example.com},
timestamp = {2013-04-11T17:20:44Z},
urldate = {2013-04-10},
date = {2004}
}

@book{cit3,
location = {Location},
title = {Title Title},
timestamp = {2016-02-01T21:50:03Z},
langid = {english},
publisher = {Publisher},
author = {Author, Name},
date = {2001}
}

\end{filecontents}

\begin{document}

\begin{minipage}{\textwidth}

Bla bla\footnote{\cite[]{cit1}, \url{http://www.website.com}}.
Bla\footnote{\cite[]{cit2}, \url{http://www.example.com}}.
BLA BLA\footcite[]{cit1}
Blaaa blaa bla\footcite[]{cit3}.

\end{minipage}

\end{document}


Output:

Since we need to modify the citation commands, the solution depends on the style quite a lot and biblatex-apa's cite macros differ from the standard ones in authortitle quite a bit, this is why your attempt didn't work.

It is probably easiest to modify the cite macro directly here (one could change cite:plabelyear+extrayear but that could interfere with other commands)

\makeatletter
\renewbibmacro*{cite}{%
\iffieldequals{namehash}{\cbx@lasthash}
% Multiple cites in one command
{\setunit{\compcitedelim}%
\usebibmacro{cite:plabelyear+extrayear}}%
% Single cite
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldequalstr{entrytype}{patent}}
% No author/editor
{\usebibmacro{cite:noname}%
\setunit{\nameyeardelim}%
\usebibmacro{cite:plabelyear+extrayear}%
\savefield{namehash}{\cbx@lasthash}}
% Normal cite
{\ifnameundef{shortauthor}
{\printnames[labelname][-\value{listtotal}]{labelname}}%
{\cbx@apa@ifnamesaved
{\printnames{shortauthor}}
\setunit{\nameyeardelim}%
\usebibmacro{cite:plabelyear+extrayear}%
\savefield{namehash}{\cbx@lasthash}}}%
\printfield[citeurl]{url}%<--- and so is this
\setunit{\multicitedelim}}
\makeatother


is a copy of the definition from apa.cbx with two lines added in towards the end.

MWE

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage[babel]{csquotes}
\usepackage[style=apa,backend=biber]{biblatex}
\DeclareLanguageMapping{italian}{italian-apa}

%\renewbibmacro*{cite:title}{%
%\printtext[bibhyperref]{\printfield[citetitle]{labeltitle}
%\iffieldundef{url}{}{\nametitledelim\printfield{url}}}}

\makeatletter
\renewbibmacro*{cite}{%
\iffieldequals{namehash}{\cbx@lasthash}
% Multiple cites in one command
{\setunit{\compcitedelim}%
\usebibmacro{cite:plabelyear+extrayear}}%
% Single cite
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldequalstr{entrytype}{patent}}
% No author/editor
{\usebibmacro{cite:noname}%
\setunit{\nameyeardelim}%
\usebibmacro{cite:plabelyear+extrayear}%
\savefield{namehash}{\cbx@lasthash}}
% Normal cite
{\ifnameundef{shortauthor}
{\printnames[labelname][-\value{listtotal}]{labelname}}%
{\cbx@apa@ifnamesaved
{\printnames{shortauthor}}
\setunit{\nameyeardelim}%
\usebibmacro{cite:plabelyear+extrayear}%
\savefield{namehash}{\cbx@lasthash}}}%
\printfield[citeurl]{url}%<--- and so is this
\setunit{\multicitedelim}}
\makeatother

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@online{cit1,
title = {Title},
url = {http://www.website.com},
urldate = {2013-04-10},
date = {2004}
}

@report{cit2,
author = {BBBAuthor, Name},
title = {Title Title Title},
url = {http://www.example.com},
urldate = {2013-04-10},
date = {2004}
}

@book{cit3,
location = {Location},
title = {Title Title},
langid = {english},
publisher = {Publisher},
author = {Author, Name},
date = {2001}
}

\end{filecontents}

\begin{document}
Bla bla\footcite[]{cit1}.
Bla\footcite[]{cit2}
BLA BLA\footcite[]{cit1}
Blaaa blaa bla\footcite[]{cit3}.


• Note that in the MWE I could do away with the bibfilters and use type=online and nottype=online instead. – moewe Feb 17 '16 at 7:28
• @CarCaSSa Glad to be of help. You will see a difference between the bibfilters and the type/nottype thingy once you start citing say @collections or @inbook works. – moewe Feb 17 '16 at 9:15