create a hyperlink by using the url stored in the bibliography reference?












2














im wondering if i can create a hyperlink that automaticaly uses the bib file stored tag 'url' somehow? Just to prevent mistakes in linking to a reference and to a websource in the same text like:



mwe:



documentclass{article}
usepackage{filecontents}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {{Use-Case 2.0 ebook}},
journal = {Ivar Jacobson International},
year = {2014},
month = {Jul},
note = {[Online; accessed 25. Dec. 2018]},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}
}
end{filecontents}
addbibresource{jobname.bib}

begin{document}
href{https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}{sometext} footcite{UseCase20}
printbibliography
end{document}


i wold like to something like this work:



documentclass{article}
usepackage{filecontents}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {{Use-Case 2.0 ebook}},
journal = {Ivar Jacobson International},
year = {2014},
month = {Jul},
note = {[Online; accessed 25. Dec. 2018]},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}
}
end{filecontents}
addbibresource{jobname.bib}

begin{document}
href{citeurl{UseCase20}}{sometext} footcite{UseCase20}
printbibliography
end{document}


but unfortunately this breaks at l.18;




href{citeurl{UseCase20}}{sometext}




EDIT:



MWE with all tests:



documentclass{article}
usepackage{filecontents}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {{Use-Case 2.0 ebook}},
journal = {Ivar Jacobson International},
year = {2014},
month = {Jul},
note = {[Online; accessed 25. Dec. 2018]},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}
}
end{filecontents}
addbibresource{jobname.bib}
%https://tex.stackexchange.com/a/413372/118709
DeclareCiteCommand{citelink}
{boolfalse{citetracker}%
boolfalse{pagetracker}%
usebibmacro{prenote}}
{iffieldundef{postnote}
{href{thefield{url}}{printfield{title}}}
{href{thefield{url}}{thefield{postnote}}}}
{multicitedelim}
{}
% https://tex.stackexchange.com/a/412927/118709
DeclareCiteCommand{citeqrurl}
{boolfalse{citetracker}%
boolfalse{pagetracker}%
usebibmacro{prenote}}
{qrcode{thefield{url}}}
{multicitedelim}
{usebibmacro{postnote}}
% https://tex.stackexchange.com/a/413519/118709
DeclareCiteCommand{geturl}
{boolfalse{citetracker}boolfalse{pagetracker}}
{iffieldundef{postnote}
{xdefbiburl{thefield{url}}}
{%
edefgeturlTmpCmd{csfield{postnote}}%
expandafterxdefgeturlTmpCmd{thefield{url}}%
}%
}
{}
{}
begin{document}
~\
citelink{sometext}{UseCase20}footcite{UseCase20}\
~\
citeqrurl{sometext}{UseCase20}footcite{UseCase20}\
~\
geturl{UseCase20}
%The href{biburl}{UseCase}footcite{UseCase20}\.
printbibliography
end{document}









share|improve this question
























  • citeurl can't be used as argument to href, you need to define your own macro, cf. tex.stackexchange.com/q/413365/35864 and tex.stackexchange.com/q/412924/35864.
    – moewe
    2 days ago












  • see above i tested all 3 types of macro but none makes a klickable link to the url... the last test even breaks, so its commented.
    – novski
    2 days ago










  • The correct syntax for citelink would have been citelink[sometext]{UseCase20}. citeqrurl as implemented in the linked answer was intended for a different use case and would have to be tweaked for yours. The last solution worked for me as well (even though I find it much less elegant for this use case).
    – moewe
    2 days ago
















2














im wondering if i can create a hyperlink that automaticaly uses the bib file stored tag 'url' somehow? Just to prevent mistakes in linking to a reference and to a websource in the same text like:



mwe:



documentclass{article}
usepackage{filecontents}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {{Use-Case 2.0 ebook}},
journal = {Ivar Jacobson International},
year = {2014},
month = {Jul},
note = {[Online; accessed 25. Dec. 2018]},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}
}
end{filecontents}
addbibresource{jobname.bib}

begin{document}
href{https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}{sometext} footcite{UseCase20}
printbibliography
end{document}


i wold like to something like this work:



documentclass{article}
usepackage{filecontents}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {{Use-Case 2.0 ebook}},
journal = {Ivar Jacobson International},
year = {2014},
month = {Jul},
note = {[Online; accessed 25. Dec. 2018]},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}
}
end{filecontents}
addbibresource{jobname.bib}

begin{document}
href{citeurl{UseCase20}}{sometext} footcite{UseCase20}
printbibliography
end{document}


but unfortunately this breaks at l.18;




href{citeurl{UseCase20}}{sometext}




EDIT:



MWE with all tests:



documentclass{article}
usepackage{filecontents}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {{Use-Case 2.0 ebook}},
journal = {Ivar Jacobson International},
year = {2014},
month = {Jul},
note = {[Online; accessed 25. Dec. 2018]},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}
}
end{filecontents}
addbibresource{jobname.bib}
%https://tex.stackexchange.com/a/413372/118709
DeclareCiteCommand{citelink}
{boolfalse{citetracker}%
boolfalse{pagetracker}%
usebibmacro{prenote}}
{iffieldundef{postnote}
{href{thefield{url}}{printfield{title}}}
{href{thefield{url}}{thefield{postnote}}}}
{multicitedelim}
{}
% https://tex.stackexchange.com/a/412927/118709
DeclareCiteCommand{citeqrurl}
{boolfalse{citetracker}%
boolfalse{pagetracker}%
usebibmacro{prenote}}
{qrcode{thefield{url}}}
{multicitedelim}
{usebibmacro{postnote}}
% https://tex.stackexchange.com/a/413519/118709
DeclareCiteCommand{geturl}
{boolfalse{citetracker}boolfalse{pagetracker}}
{iffieldundef{postnote}
{xdefbiburl{thefield{url}}}
{%
edefgeturlTmpCmd{csfield{postnote}}%
expandafterxdefgeturlTmpCmd{thefield{url}}%
}%
}
{}
{}
begin{document}
~\
citelink{sometext}{UseCase20}footcite{UseCase20}\
~\
citeqrurl{sometext}{UseCase20}footcite{UseCase20}\
~\
geturl{UseCase20}
%The href{biburl}{UseCase}footcite{UseCase20}\.
printbibliography
end{document}









share|improve this question
























  • citeurl can't be used as argument to href, you need to define your own macro, cf. tex.stackexchange.com/q/413365/35864 and tex.stackexchange.com/q/412924/35864.
    – moewe
    2 days ago












  • see above i tested all 3 types of macro but none makes a klickable link to the url... the last test even breaks, so its commented.
    – novski
    2 days ago










  • The correct syntax for citelink would have been citelink[sometext]{UseCase20}. citeqrurl as implemented in the linked answer was intended for a different use case and would have to be tweaked for yours. The last solution worked for me as well (even though I find it much less elegant for this use case).
    – moewe
    2 days ago














2












2








2


0





im wondering if i can create a hyperlink that automaticaly uses the bib file stored tag 'url' somehow? Just to prevent mistakes in linking to a reference and to a websource in the same text like:



mwe:



documentclass{article}
usepackage{filecontents}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {{Use-Case 2.0 ebook}},
journal = {Ivar Jacobson International},
year = {2014},
month = {Jul},
note = {[Online; accessed 25. Dec. 2018]},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}
}
end{filecontents}
addbibresource{jobname.bib}

begin{document}
href{https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}{sometext} footcite{UseCase20}
printbibliography
end{document}


i wold like to something like this work:



documentclass{article}
usepackage{filecontents}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {{Use-Case 2.0 ebook}},
journal = {Ivar Jacobson International},
year = {2014},
month = {Jul},
note = {[Online; accessed 25. Dec. 2018]},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}
}
end{filecontents}
addbibresource{jobname.bib}

begin{document}
href{citeurl{UseCase20}}{sometext} footcite{UseCase20}
printbibliography
end{document}


but unfortunately this breaks at l.18;




href{citeurl{UseCase20}}{sometext}




EDIT:



MWE with all tests:



documentclass{article}
usepackage{filecontents}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {{Use-Case 2.0 ebook}},
journal = {Ivar Jacobson International},
year = {2014},
month = {Jul},
note = {[Online; accessed 25. Dec. 2018]},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}
}
end{filecontents}
addbibresource{jobname.bib}
%https://tex.stackexchange.com/a/413372/118709
DeclareCiteCommand{citelink}
{boolfalse{citetracker}%
boolfalse{pagetracker}%
usebibmacro{prenote}}
{iffieldundef{postnote}
{href{thefield{url}}{printfield{title}}}
{href{thefield{url}}{thefield{postnote}}}}
{multicitedelim}
{}
% https://tex.stackexchange.com/a/412927/118709
DeclareCiteCommand{citeqrurl}
{boolfalse{citetracker}%
boolfalse{pagetracker}%
usebibmacro{prenote}}
{qrcode{thefield{url}}}
{multicitedelim}
{usebibmacro{postnote}}
% https://tex.stackexchange.com/a/413519/118709
DeclareCiteCommand{geturl}
{boolfalse{citetracker}boolfalse{pagetracker}}
{iffieldundef{postnote}
{xdefbiburl{thefield{url}}}
{%
edefgeturlTmpCmd{csfield{postnote}}%
expandafterxdefgeturlTmpCmd{thefield{url}}%
}%
}
{}
{}
begin{document}
~\
citelink{sometext}{UseCase20}footcite{UseCase20}\
~\
citeqrurl{sometext}{UseCase20}footcite{UseCase20}\
~\
geturl{UseCase20}
%The href{biburl}{UseCase}footcite{UseCase20}\.
printbibliography
end{document}









share|improve this question















im wondering if i can create a hyperlink that automaticaly uses the bib file stored tag 'url' somehow? Just to prevent mistakes in linking to a reference and to a websource in the same text like:



mwe:



documentclass{article}
usepackage{filecontents}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {{Use-Case 2.0 ebook}},
journal = {Ivar Jacobson International},
year = {2014},
month = {Jul},
note = {[Online; accessed 25. Dec. 2018]},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}
}
end{filecontents}
addbibresource{jobname.bib}

begin{document}
href{https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}{sometext} footcite{UseCase20}
printbibliography
end{document}


i wold like to something like this work:



documentclass{article}
usepackage{filecontents}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {{Use-Case 2.0 ebook}},
journal = {Ivar Jacobson International},
year = {2014},
month = {Jul},
note = {[Online; accessed 25. Dec. 2018]},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}
}
end{filecontents}
addbibresource{jobname.bib}

begin{document}
href{citeurl{UseCase20}}{sometext} footcite{UseCase20}
printbibliography
end{document}


but unfortunately this breaks at l.18;




href{citeurl{UseCase20}}{sometext}




EDIT:



MWE with all tests:



documentclass{article}
usepackage{filecontents}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {{Use-Case 2.0 ebook}},
journal = {Ivar Jacobson International},
year = {2014},
month = {Jul},
note = {[Online; accessed 25. Dec. 2018]},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}
}
end{filecontents}
addbibresource{jobname.bib}
%https://tex.stackexchange.com/a/413372/118709
DeclareCiteCommand{citelink}
{boolfalse{citetracker}%
boolfalse{pagetracker}%
usebibmacro{prenote}}
{iffieldundef{postnote}
{href{thefield{url}}{printfield{title}}}
{href{thefield{url}}{thefield{postnote}}}}
{multicitedelim}
{}
% https://tex.stackexchange.com/a/412927/118709
DeclareCiteCommand{citeqrurl}
{boolfalse{citetracker}%
boolfalse{pagetracker}%
usebibmacro{prenote}}
{qrcode{thefield{url}}}
{multicitedelim}
{usebibmacro{postnote}}
% https://tex.stackexchange.com/a/413519/118709
DeclareCiteCommand{geturl}
{boolfalse{citetracker}boolfalse{pagetracker}}
{iffieldundef{postnote}
{xdefbiburl{thefield{url}}}
{%
edefgeturlTmpCmd{csfield{postnote}}%
expandafterxdefgeturlTmpCmd{thefield{url}}%
}%
}
{}
{}
begin{document}
~\
citelink{sometext}{UseCase20}footcite{UseCase20}\
~\
citeqrurl{sometext}{UseCase20}footcite{UseCase20}\
~\
geturl{UseCase20}
%The href{biburl}{UseCase}footcite{UseCase20}\.
printbibliography
end{document}






biblatex url hyperlink href






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago

























asked 2 days ago









novski

49739




49739












  • citeurl can't be used as argument to href, you need to define your own macro, cf. tex.stackexchange.com/q/413365/35864 and tex.stackexchange.com/q/412924/35864.
    – moewe
    2 days ago












  • see above i tested all 3 types of macro but none makes a klickable link to the url... the last test even breaks, so its commented.
    – novski
    2 days ago










  • The correct syntax for citelink would have been citelink[sometext]{UseCase20}. citeqrurl as implemented in the linked answer was intended for a different use case and would have to be tweaked for yours. The last solution worked for me as well (even though I find it much less elegant for this use case).
    – moewe
    2 days ago


















  • citeurl can't be used as argument to href, you need to define your own macro, cf. tex.stackexchange.com/q/413365/35864 and tex.stackexchange.com/q/412924/35864.
    – moewe
    2 days ago












  • see above i tested all 3 types of macro but none makes a klickable link to the url... the last test even breaks, so its commented.
    – novski
    2 days ago










  • The correct syntax for citelink would have been citelink[sometext]{UseCase20}. citeqrurl as implemented in the linked answer was intended for a different use case and would have to be tweaked for yours. The last solution worked for me as well (even though I find it much less elegant for this use case).
    – moewe
    2 days ago
















citeurl can't be used as argument to href, you need to define your own macro, cf. tex.stackexchange.com/q/413365/35864 and tex.stackexchange.com/q/412924/35864.
– moewe
2 days ago






citeurl can't be used as argument to href, you need to define your own macro, cf. tex.stackexchange.com/q/413365/35864 and tex.stackexchange.com/q/412924/35864.
– moewe
2 days ago














see above i tested all 3 types of macro but none makes a klickable link to the url... the last test even breaks, so its commented.
– novski
2 days ago




see above i tested all 3 types of macro but none makes a klickable link to the url... the last test even breaks, so its commented.
– novski
2 days ago












The correct syntax for citelink would have been citelink[sometext]{UseCase20}. citeqrurl as implemented in the linked answer was intended for a different use case and would have to be tweaked for yours. The last solution worked for me as well (even though I find it much less elegant for this use case).
– moewe
2 days ago




The correct syntax for citelink would have been citelink[sometext]{UseCase20}. citeqrurl as implemented in the linked answer was intended for a different use case and would have to be tweaked for yours. The last solution worked for me as well (even though I find it much less elegant for this use case).
– moewe
2 days ago










1 Answer
1






active

oldest

votes


















4














citeurl does not return the URL of the entry in question (in an expandable way), instead it is meant to print the formatted URL. That means that it can't be used as the URI argument for href. If you want to be able to href the URL of an entry to arbitrary text, the simplest way is to create a new cite... macro. Since cite... macros have a fixed argument structure the one below works as follows



citehrefurl[<arbitrary text that is going ot be linked>]{<entrykey>}


You could create a new command with arbitrary arguments. Usually I strongly advise against creating new commands from cite... commands via newcommand, but in this case we can make an exception.



documentclass{article}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}

DeclareCiteCommand{citehrefurl}
{boolfalse{citetracker}%
boolfalse{pagetracker}}
{iffieldundef{url}
{PackageWarning{biblatex}
{The entry thefield{entrykey} has no URL.MessageBreak
No link will be created}%
printfield{postnote}}
{href{thefield{url}}
{iffieldundef{postnote}
{PackageWarning{biblatex}
{Text argument missing,MessageBreak
using the title for entryMessageBreak
thefield{entrykey}}%
printfield[citetitle]{labeltitle}}
{printfield{postnote}}}}}
{}
{}

newcommand*{citehrefurlwrap}[2]{citehrefurl[#2]{#1}}

usepackage{filecontents}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {Use-Case 2.0 ebook},
author = {Ivar Jacobson and Ian Spence and Kurt Bittner},
date = {2011-12},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook},
urldate = {2018-12-25},
}
end{filecontents}
addbibresource{jobname.bib}

begin{document}
citehrefurl{UseCase20}

citehrefurl[some text]{UseCase20}

citehrefurlwrap{UseCase20}{some other text}

citeurl{UseCase20}

href{https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}{sometext}

printbibliography
end{document}


Sorry there is no image at the moment. I'm having trouble uploading them. Feel free to add a screenshot of the result if you like.



This is basically a slightly modified version of jakun's citelink from their answer to How to create a link to a URL provided in a bib file with custom text which was in turn inspired by Create QR-code from citeurl.






share|improve this answer























  • exept the last ordinary href link none of the above creates a click able link in my case.
    – novski
    2 days ago










  • @novski What exact result do you get instead? Do note that the url field in your example was faulty: It contained to much whitespace. I fixed that in my code.
    – moewe
    2 days ago












  • sorry for that. i corrected the mwe. but i copied your mwe from this answer. and i get 3 lines of "UseCase20" and one line "sometext" only "sometext" is clickable...
    – novski
    2 days ago










  • Take my MWE and compile it in a new, empty folder with LaTeX, Biber, LaTeX, LaTeX. If you get bold UseCase20 as output that means that biblatex failed to resolve the citation. That should have little to do with the macro itself.
    – moewe
    2 days ago












  • @novski To see that the code above works as intended check out v1.overleaf.com/read/chsgpnfhwhvs.
    – moewe
    2 days ago













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467262%2fcreate-a-hyperlink-by-using-the-url-stored-in-the-bibliography-reference%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














citeurl does not return the URL of the entry in question (in an expandable way), instead it is meant to print the formatted URL. That means that it can't be used as the URI argument for href. If you want to be able to href the URL of an entry to arbitrary text, the simplest way is to create a new cite... macro. Since cite... macros have a fixed argument structure the one below works as follows



citehrefurl[<arbitrary text that is going ot be linked>]{<entrykey>}


You could create a new command with arbitrary arguments. Usually I strongly advise against creating new commands from cite... commands via newcommand, but in this case we can make an exception.



documentclass{article}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}

DeclareCiteCommand{citehrefurl}
{boolfalse{citetracker}%
boolfalse{pagetracker}}
{iffieldundef{url}
{PackageWarning{biblatex}
{The entry thefield{entrykey} has no URL.MessageBreak
No link will be created}%
printfield{postnote}}
{href{thefield{url}}
{iffieldundef{postnote}
{PackageWarning{biblatex}
{Text argument missing,MessageBreak
using the title for entryMessageBreak
thefield{entrykey}}%
printfield[citetitle]{labeltitle}}
{printfield{postnote}}}}}
{}
{}

newcommand*{citehrefurlwrap}[2]{citehrefurl[#2]{#1}}

usepackage{filecontents}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {Use-Case 2.0 ebook},
author = {Ivar Jacobson and Ian Spence and Kurt Bittner},
date = {2011-12},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook},
urldate = {2018-12-25},
}
end{filecontents}
addbibresource{jobname.bib}

begin{document}
citehrefurl{UseCase20}

citehrefurl[some text]{UseCase20}

citehrefurlwrap{UseCase20}{some other text}

citeurl{UseCase20}

href{https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}{sometext}

printbibliography
end{document}


Sorry there is no image at the moment. I'm having trouble uploading them. Feel free to add a screenshot of the result if you like.



This is basically a slightly modified version of jakun's citelink from their answer to How to create a link to a URL provided in a bib file with custom text which was in turn inspired by Create QR-code from citeurl.






share|improve this answer























  • exept the last ordinary href link none of the above creates a click able link in my case.
    – novski
    2 days ago










  • @novski What exact result do you get instead? Do note that the url field in your example was faulty: It contained to much whitespace. I fixed that in my code.
    – moewe
    2 days ago












  • sorry for that. i corrected the mwe. but i copied your mwe from this answer. and i get 3 lines of "UseCase20" and one line "sometext" only "sometext" is clickable...
    – novski
    2 days ago










  • Take my MWE and compile it in a new, empty folder with LaTeX, Biber, LaTeX, LaTeX. If you get bold UseCase20 as output that means that biblatex failed to resolve the citation. That should have little to do with the macro itself.
    – moewe
    2 days ago












  • @novski To see that the code above works as intended check out v1.overleaf.com/read/chsgpnfhwhvs.
    – moewe
    2 days ago


















4














citeurl does not return the URL of the entry in question (in an expandable way), instead it is meant to print the formatted URL. That means that it can't be used as the URI argument for href. If you want to be able to href the URL of an entry to arbitrary text, the simplest way is to create a new cite... macro. Since cite... macros have a fixed argument structure the one below works as follows



citehrefurl[<arbitrary text that is going ot be linked>]{<entrykey>}


You could create a new command with arbitrary arguments. Usually I strongly advise against creating new commands from cite... commands via newcommand, but in this case we can make an exception.



documentclass{article}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}

DeclareCiteCommand{citehrefurl}
{boolfalse{citetracker}%
boolfalse{pagetracker}}
{iffieldundef{url}
{PackageWarning{biblatex}
{The entry thefield{entrykey} has no URL.MessageBreak
No link will be created}%
printfield{postnote}}
{href{thefield{url}}
{iffieldundef{postnote}
{PackageWarning{biblatex}
{Text argument missing,MessageBreak
using the title for entryMessageBreak
thefield{entrykey}}%
printfield[citetitle]{labeltitle}}
{printfield{postnote}}}}}
{}
{}

newcommand*{citehrefurlwrap}[2]{citehrefurl[#2]{#1}}

usepackage{filecontents}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {Use-Case 2.0 ebook},
author = {Ivar Jacobson and Ian Spence and Kurt Bittner},
date = {2011-12},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook},
urldate = {2018-12-25},
}
end{filecontents}
addbibresource{jobname.bib}

begin{document}
citehrefurl{UseCase20}

citehrefurl[some text]{UseCase20}

citehrefurlwrap{UseCase20}{some other text}

citeurl{UseCase20}

href{https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}{sometext}

printbibliography
end{document}


Sorry there is no image at the moment. I'm having trouble uploading them. Feel free to add a screenshot of the result if you like.



This is basically a slightly modified version of jakun's citelink from their answer to How to create a link to a URL provided in a bib file with custom text which was in turn inspired by Create QR-code from citeurl.






share|improve this answer























  • exept the last ordinary href link none of the above creates a click able link in my case.
    – novski
    2 days ago










  • @novski What exact result do you get instead? Do note that the url field in your example was faulty: It contained to much whitespace. I fixed that in my code.
    – moewe
    2 days ago












  • sorry for that. i corrected the mwe. but i copied your mwe from this answer. and i get 3 lines of "UseCase20" and one line "sometext" only "sometext" is clickable...
    – novski
    2 days ago










  • Take my MWE and compile it in a new, empty folder with LaTeX, Biber, LaTeX, LaTeX. If you get bold UseCase20 as output that means that biblatex failed to resolve the citation. That should have little to do with the macro itself.
    – moewe
    2 days ago












  • @novski To see that the code above works as intended check out v1.overleaf.com/read/chsgpnfhwhvs.
    – moewe
    2 days ago
















4












4








4






citeurl does not return the URL of the entry in question (in an expandable way), instead it is meant to print the formatted URL. That means that it can't be used as the URI argument for href. If you want to be able to href the URL of an entry to arbitrary text, the simplest way is to create a new cite... macro. Since cite... macros have a fixed argument structure the one below works as follows



citehrefurl[<arbitrary text that is going ot be linked>]{<entrykey>}


You could create a new command with arbitrary arguments. Usually I strongly advise against creating new commands from cite... commands via newcommand, but in this case we can make an exception.



documentclass{article}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}

DeclareCiteCommand{citehrefurl}
{boolfalse{citetracker}%
boolfalse{pagetracker}}
{iffieldundef{url}
{PackageWarning{biblatex}
{The entry thefield{entrykey} has no URL.MessageBreak
No link will be created}%
printfield{postnote}}
{href{thefield{url}}
{iffieldundef{postnote}
{PackageWarning{biblatex}
{Text argument missing,MessageBreak
using the title for entryMessageBreak
thefield{entrykey}}%
printfield[citetitle]{labeltitle}}
{printfield{postnote}}}}}
{}
{}

newcommand*{citehrefurlwrap}[2]{citehrefurl[#2]{#1}}

usepackage{filecontents}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {Use-Case 2.0 ebook},
author = {Ivar Jacobson and Ian Spence and Kurt Bittner},
date = {2011-12},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook},
urldate = {2018-12-25},
}
end{filecontents}
addbibresource{jobname.bib}

begin{document}
citehrefurl{UseCase20}

citehrefurl[some text]{UseCase20}

citehrefurlwrap{UseCase20}{some other text}

citeurl{UseCase20}

href{https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}{sometext}

printbibliography
end{document}


Sorry there is no image at the moment. I'm having trouble uploading them. Feel free to add a screenshot of the result if you like.



This is basically a slightly modified version of jakun's citelink from their answer to How to create a link to a URL provided in a bib file with custom text which was in turn inspired by Create QR-code from citeurl.






share|improve this answer














citeurl does not return the URL of the entry in question (in an expandable way), instead it is meant to print the formatted URL. That means that it can't be used as the URI argument for href. If you want to be able to href the URL of an entry to arbitrary text, the simplest way is to create a new cite... macro. Since cite... macros have a fixed argument structure the one below works as follows



citehrefurl[<arbitrary text that is going ot be linked>]{<entrykey>}


You could create a new command with arbitrary arguments. Usually I strongly advise against creating new commands from cite... commands via newcommand, but in this case we can make an exception.



documentclass{article}
usepackage[style=nature, url=true]{biblatex}
usepackage{hyperref}

DeclareCiteCommand{citehrefurl}
{boolfalse{citetracker}%
boolfalse{pagetracker}}
{iffieldundef{url}
{PackageWarning{biblatex}
{The entry thefield{entrykey} has no URL.MessageBreak
No link will be created}%
printfield{postnote}}
{href{thefield{url}}
{iffieldundef{postnote}
{PackageWarning{biblatex}
{Text argument missing,MessageBreak
using the title for entryMessageBreak
thefield{entrykey}}%
printfield[citetitle]{labeltitle}}
{printfield{postnote}}}}}
{}
{}

newcommand*{citehrefurlwrap}[2]{citehrefurl[#2]{#1}}

usepackage{filecontents}
begin{filecontents}{jobname.bib}
@online{UseCase20,
title = {Use-Case 2.0 ebook},
author = {Ivar Jacobson and Ian Spence and Kurt Bittner},
date = {2011-12},
url = {https://www.ivarjacobson.com/publications/white-papers/use-case-ebook},
urldate = {2018-12-25},
}
end{filecontents}
addbibresource{jobname.bib}

begin{document}
citehrefurl{UseCase20}

citehrefurl[some text]{UseCase20}

citehrefurlwrap{UseCase20}{some other text}

citeurl{UseCase20}

href{https://www.ivarjacobson.com/publications/white-papers/use-case-ebook}{sometext}

printbibliography
end{document}


Sorry there is no image at the moment. I'm having trouble uploading them. Feel free to add a screenshot of the result if you like.



This is basically a slightly modified version of jakun's citelink from their answer to How to create a link to a URL provided in a bib file with custom text which was in turn inspired by Create QR-code from citeurl.







share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago

























answered 2 days ago









moewe

86.1k9109332




86.1k9109332












  • exept the last ordinary href link none of the above creates a click able link in my case.
    – novski
    2 days ago










  • @novski What exact result do you get instead? Do note that the url field in your example was faulty: It contained to much whitespace. I fixed that in my code.
    – moewe
    2 days ago












  • sorry for that. i corrected the mwe. but i copied your mwe from this answer. and i get 3 lines of "UseCase20" and one line "sometext" only "sometext" is clickable...
    – novski
    2 days ago










  • Take my MWE and compile it in a new, empty folder with LaTeX, Biber, LaTeX, LaTeX. If you get bold UseCase20 as output that means that biblatex failed to resolve the citation. That should have little to do with the macro itself.
    – moewe
    2 days ago












  • @novski To see that the code above works as intended check out v1.overleaf.com/read/chsgpnfhwhvs.
    – moewe
    2 days ago




















  • exept the last ordinary href link none of the above creates a click able link in my case.
    – novski
    2 days ago










  • @novski What exact result do you get instead? Do note that the url field in your example was faulty: It contained to much whitespace. I fixed that in my code.
    – moewe
    2 days ago












  • sorry for that. i corrected the mwe. but i copied your mwe from this answer. and i get 3 lines of "UseCase20" and one line "sometext" only "sometext" is clickable...
    – novski
    2 days ago










  • Take my MWE and compile it in a new, empty folder with LaTeX, Biber, LaTeX, LaTeX. If you get bold UseCase20 as output that means that biblatex failed to resolve the citation. That should have little to do with the macro itself.
    – moewe
    2 days ago












  • @novski To see that the code above works as intended check out v1.overleaf.com/read/chsgpnfhwhvs.
    – moewe
    2 days ago


















exept the last ordinary href link none of the above creates a click able link in my case.
– novski
2 days ago




exept the last ordinary href link none of the above creates a click able link in my case.
– novski
2 days ago












@novski What exact result do you get instead? Do note that the url field in your example was faulty: It contained to much whitespace. I fixed that in my code.
– moewe
2 days ago






@novski What exact result do you get instead? Do note that the url field in your example was faulty: It contained to much whitespace. I fixed that in my code.
– moewe
2 days ago














sorry for that. i corrected the mwe. but i copied your mwe from this answer. and i get 3 lines of "UseCase20" and one line "sometext" only "sometext" is clickable...
– novski
2 days ago




sorry for that. i corrected the mwe. but i copied your mwe from this answer. and i get 3 lines of "UseCase20" and one line "sometext" only "sometext" is clickable...
– novski
2 days ago












Take my MWE and compile it in a new, empty folder with LaTeX, Biber, LaTeX, LaTeX. If you get bold UseCase20 as output that means that biblatex failed to resolve the citation. That should have little to do with the macro itself.
– moewe
2 days ago






Take my MWE and compile it in a new, empty folder with LaTeX, Biber, LaTeX, LaTeX. If you get bold UseCase20 as output that means that biblatex failed to resolve the citation. That should have little to do with the macro itself.
– moewe
2 days ago














@novski To see that the code above works as intended check out v1.overleaf.com/read/chsgpnfhwhvs.
– moewe
2 days ago






@novski To see that the code above works as intended check out v1.overleaf.com/read/chsgpnfhwhvs.
– moewe
2 days ago




















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467262%2fcreate-a-hyperlink-by-using-the-url-stored-in-the-bibliography-reference%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

Origin of the phrase “under your belt”?