Enabling double way for bibliography with url: Both bibtex and biblatex (biber)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I am trying to make a document to accept both bibtex and biblatex (during different compilations of course) and I have a problem because:



  1. In bibtex I have to add url command inside every url (really many entries)

  2. But biblatex doesn't accept this (already there and so, it supposes it is a part of my url) and giving unwanted results.

Here is the code:



documentclassarticle
usepackagefilecontents
% UseBibLaTex is a variable that if is less than 1 the document
% will have to compiled with `bibTeX`... else with biber
defUseBibLaTeX0
% ``url'' package is used in order to make LaTeX to break the urls
% in places like the bibliography combined with the next (upcoming)
% command
%usepackagebreakurl
usepackage[hyphens]url
Urlmuskip=0mu plus 1mu

ifnumUseBibLaTeX>0
usepackage[backend=biber,style=authoryear]biblatex
newcommandmyurl[1]#1
DeclareFieldFormaturlfootnotesize URL:space%expandafter%noexpand
myurl#1
addbibresourcemyBib.bib
else
% ``natbib'' package offers the bigger ammount possibilities in bibliography
% formating
letmyurlurl
usepackagenatbib
fi


beginfilecontents*myBib.bib
@Articlecite1,
title=One Article with a url that has to break both in bibtex and biblatex,
author=Someone NotMe and Someother Me,
year=2018,
month=10,
url=urlhttp://A-long-URL-that-has-to-break-through-lines-and-biber-has-to-ignore-the-textbackslash url-command,
doi=http://dx.doi.org/10.1038/nphys1170

endfilecontents*

titleDouble Functionality about Bibliography
authorKonstantinos Leledakis
dateOctober 2018

begindocument

maketitle

nocite*
ifnumUseBibLaTeX>0
printbibliography
else
bibliographystyleagsm
beginsloppypar
bibliographymyBib
endsloppypar
fi



enddocument


The output of the above code, is as expected... but if I change
the command defUseBibLaTeX0 to defUseBibLaTeX1 I get (an expected as a noob about biber but...) unwanted result:



enter image description here



Already tried some things like noexpand or expandafter that are commented in my code but could not make it work as I wanted.










share|improve this question



















  • 2




    As far as biblatex is concerned the url field must not contain url or anything else other than the raw URL. I thought most .bst files (that support URLs) would handle the situation similarly.
    – moewe
    1 hour ago










  • @moewe... I understood that, but tried to change the way that handles this field (possibly only its format and thus failed). I suppose there is a way, at least change the bibtex way (and adding this command to every url field autamaticaly) if biblatex way can not adjusted. I tried with changes in biblatex first because I thought is more powerful to handle such situations
    – koleygr
    1 hour ago










  • I could accept a new kind of entry too that will be added there like note, but trying to avoid it. The final result I am after is just to not need to change the bibliography file from compilation to compilation... And just preffer to be able to use the already existing fields in bibliography files (with or without addition of url command) without changes... But if not posible, I am going to add them as a note
    – koleygr
    1 hour ago














up vote
2
down vote

favorite












I am trying to make a document to accept both bibtex and biblatex (during different compilations of course) and I have a problem because:



  1. In bibtex I have to add url command inside every url (really many entries)

  2. But biblatex doesn't accept this (already there and so, it supposes it is a part of my url) and giving unwanted results.

Here is the code:



documentclassarticle
usepackagefilecontents
% UseBibLaTex is a variable that if is less than 1 the document
% will have to compiled with `bibTeX`... else with biber
defUseBibLaTeX0
% ``url'' package is used in order to make LaTeX to break the urls
% in places like the bibliography combined with the next (upcoming)
% command
%usepackagebreakurl
usepackage[hyphens]url
Urlmuskip=0mu plus 1mu

ifnumUseBibLaTeX>0
usepackage[backend=biber,style=authoryear]biblatex
newcommandmyurl[1]#1
DeclareFieldFormaturlfootnotesize URL:space%expandafter%noexpand
myurl#1
addbibresourcemyBib.bib
else
% ``natbib'' package offers the bigger ammount possibilities in bibliography
% formating
letmyurlurl
usepackagenatbib
fi


beginfilecontents*myBib.bib
@Articlecite1,
title=One Article with a url that has to break both in bibtex and biblatex,
author=Someone NotMe and Someother Me,
year=2018,
month=10,
url=urlhttp://A-long-URL-that-has-to-break-through-lines-and-biber-has-to-ignore-the-textbackslash url-command,
doi=http://dx.doi.org/10.1038/nphys1170

endfilecontents*

titleDouble Functionality about Bibliography
authorKonstantinos Leledakis
dateOctober 2018

begindocument

maketitle

nocite*
ifnumUseBibLaTeX>0
printbibliography
else
bibliographystyleagsm
beginsloppypar
bibliographymyBib
endsloppypar
fi



enddocument


The output of the above code, is as expected... but if I change
the command defUseBibLaTeX0 to defUseBibLaTeX1 I get (an expected as a noob about biber but...) unwanted result:



enter image description here



Already tried some things like noexpand or expandafter that are commented in my code but could not make it work as I wanted.










share|improve this question



















  • 2




    As far as biblatex is concerned the url field must not contain url or anything else other than the raw URL. I thought most .bst files (that support URLs) would handle the situation similarly.
    – moewe
    1 hour ago










  • @moewe... I understood that, but tried to change the way that handles this field (possibly only its format and thus failed). I suppose there is a way, at least change the bibtex way (and adding this command to every url field autamaticaly) if biblatex way can not adjusted. I tried with changes in biblatex first because I thought is more powerful to handle such situations
    – koleygr
    1 hour ago










  • I could accept a new kind of entry too that will be added there like note, but trying to avoid it. The final result I am after is just to not need to change the bibliography file from compilation to compilation... And just preffer to be able to use the already existing fields in bibliography files (with or without addition of url command) without changes... But if not posible, I am going to add them as a note
    – koleygr
    1 hour ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I am trying to make a document to accept both bibtex and biblatex (during different compilations of course) and I have a problem because:



  1. In bibtex I have to add url command inside every url (really many entries)

  2. But biblatex doesn't accept this (already there and so, it supposes it is a part of my url) and giving unwanted results.

Here is the code:



documentclassarticle
usepackagefilecontents
% UseBibLaTex is a variable that if is less than 1 the document
% will have to compiled with `bibTeX`... else with biber
defUseBibLaTeX0
% ``url'' package is used in order to make LaTeX to break the urls
% in places like the bibliography combined with the next (upcoming)
% command
%usepackagebreakurl
usepackage[hyphens]url
Urlmuskip=0mu plus 1mu

ifnumUseBibLaTeX>0
usepackage[backend=biber,style=authoryear]biblatex
newcommandmyurl[1]#1
DeclareFieldFormaturlfootnotesize URL:space%expandafter%noexpand
myurl#1
addbibresourcemyBib.bib
else
% ``natbib'' package offers the bigger ammount possibilities in bibliography
% formating
letmyurlurl
usepackagenatbib
fi


beginfilecontents*myBib.bib
@Articlecite1,
title=One Article with a url that has to break both in bibtex and biblatex,
author=Someone NotMe and Someother Me,
year=2018,
month=10,
url=urlhttp://A-long-URL-that-has-to-break-through-lines-and-biber-has-to-ignore-the-textbackslash url-command,
doi=http://dx.doi.org/10.1038/nphys1170

endfilecontents*

titleDouble Functionality about Bibliography
authorKonstantinos Leledakis
dateOctober 2018

begindocument

maketitle

nocite*
ifnumUseBibLaTeX>0
printbibliography
else
bibliographystyleagsm
beginsloppypar
bibliographymyBib
endsloppypar
fi



enddocument


The output of the above code, is as expected... but if I change
the command defUseBibLaTeX0 to defUseBibLaTeX1 I get (an expected as a noob about biber but...) unwanted result:



enter image description here



Already tried some things like noexpand or expandafter that are commented in my code but could not make it work as I wanted.










share|improve this question















I am trying to make a document to accept both bibtex and biblatex (during different compilations of course) and I have a problem because:



  1. In bibtex I have to add url command inside every url (really many entries)

  2. But biblatex doesn't accept this (already there and so, it supposes it is a part of my url) and giving unwanted results.

Here is the code:



documentclassarticle
usepackagefilecontents
% UseBibLaTex is a variable that if is less than 1 the document
% will have to compiled with `bibTeX`... else with biber
defUseBibLaTeX0
% ``url'' package is used in order to make LaTeX to break the urls
% in places like the bibliography combined with the next (upcoming)
% command
%usepackagebreakurl
usepackage[hyphens]url
Urlmuskip=0mu plus 1mu

ifnumUseBibLaTeX>0
usepackage[backend=biber,style=authoryear]biblatex
newcommandmyurl[1]#1
DeclareFieldFormaturlfootnotesize URL:space%expandafter%noexpand
myurl#1
addbibresourcemyBib.bib
else
% ``natbib'' package offers the bigger ammount possibilities in bibliography
% formating
letmyurlurl
usepackagenatbib
fi


beginfilecontents*myBib.bib
@Articlecite1,
title=One Article with a url that has to break both in bibtex and biblatex,
author=Someone NotMe and Someother Me,
year=2018,
month=10,
url=urlhttp://A-long-URL-that-has-to-break-through-lines-and-biber-has-to-ignore-the-textbackslash url-command,
doi=http://dx.doi.org/10.1038/nphys1170

endfilecontents*

titleDouble Functionality about Bibliography
authorKonstantinos Leledakis
dateOctober 2018

begindocument

maketitle

nocite*
ifnumUseBibLaTeX>0
printbibliography
else
bibliographystyleagsm
beginsloppypar
bibliographymyBib
endsloppypar
fi



enddocument


The output of the above code, is as expected... but if I change
the command defUseBibLaTeX0 to defUseBibLaTeX1 I get (an expected as a noob about biber but...) unwanted result:



enter image description here



Already tried some things like noexpand or expandafter that are commented in my code but could not make it work as I wanted.







biblatex bibtex biber urls






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago

























asked 1 hour ago









koleygr

10.3k1736




10.3k1736







  • 2




    As far as biblatex is concerned the url field must not contain url or anything else other than the raw URL. I thought most .bst files (that support URLs) would handle the situation similarly.
    – moewe
    1 hour ago










  • @moewe... I understood that, but tried to change the way that handles this field (possibly only its format and thus failed). I suppose there is a way, at least change the bibtex way (and adding this command to every url field autamaticaly) if biblatex way can not adjusted. I tried with changes in biblatex first because I thought is more powerful to handle such situations
    – koleygr
    1 hour ago










  • I could accept a new kind of entry too that will be added there like note, but trying to avoid it. The final result I am after is just to not need to change the bibliography file from compilation to compilation... And just preffer to be able to use the already existing fields in bibliography files (with or without addition of url command) without changes... But if not posible, I am going to add them as a note
    – koleygr
    1 hour ago












  • 2




    As far as biblatex is concerned the url field must not contain url or anything else other than the raw URL. I thought most .bst files (that support URLs) would handle the situation similarly.
    – moewe
    1 hour ago










  • @moewe... I understood that, but tried to change the way that handles this field (possibly only its format and thus failed). I suppose there is a way, at least change the bibtex way (and adding this command to every url field autamaticaly) if biblatex way can not adjusted. I tried with changes in biblatex first because I thought is more powerful to handle such situations
    – koleygr
    1 hour ago










  • I could accept a new kind of entry too that will be added there like note, but trying to avoid it. The final result I am after is just to not need to change the bibliography file from compilation to compilation... And just preffer to be able to use the already existing fields in bibliography files (with or without addition of url command) without changes... But if not posible, I am going to add them as a note
    – koleygr
    1 hour ago







2




2




As far as biblatex is concerned the url field must not contain url or anything else other than the raw URL. I thought most .bst files (that support URLs) would handle the situation similarly.
– moewe
1 hour ago




As far as biblatex is concerned the url field must not contain url or anything else other than the raw URL. I thought most .bst files (that support URLs) would handle the situation similarly.
– moewe
1 hour ago












@moewe... I understood that, but tried to change the way that handles this field (possibly only its format and thus failed). I suppose there is a way, at least change the bibtex way (and adding this command to every url field autamaticaly) if biblatex way can not adjusted. I tried with changes in biblatex first because I thought is more powerful to handle such situations
– koleygr
1 hour ago




@moewe... I understood that, but tried to change the way that handles this field (possibly only its format and thus failed). I suppose there is a way, at least change the bibtex way (and adding this command to every url field autamaticaly) if biblatex way can not adjusted. I tried with changes in biblatex first because I thought is more powerful to handle such situations
– koleygr
1 hour ago












I could accept a new kind of entry too that will be added there like note, but trying to avoid it. The final result I am after is just to not need to change the bibliography file from compilation to compilation... And just preffer to be able to use the already existing fields in bibliography files (with or without addition of url command) without changes... But if not posible, I am going to add them as a note
– koleygr
1 hour ago




I could accept a new kind of entry too that will be added there like note, but trying to avoid it. The final result I am after is just to not need to change the bibliography file from compilation to compilation... And just preffer to be able to use the already existing fields in bibliography files (with or without addition of url command) without changes... But if not posible, I am going to add them as a note
– koleygr
1 hour ago










1 Answer
1






active

oldest

votes

















up vote
5
down vote



accepted










biblatex expects the url field to contain the URL and the URL only. No additional markup like url..., no escaping of special characters, nothing, just the verbose URL.



The problem you are seeing is that Biber applies percent encoding to the URL and this messes up your url... wrapper. (There are ways to get rid of the percent encoding, see biblatex, using space in url doesnt work, How to disable percent-encoding in URLs?, Scandinavian letters in Biblatex URL, but that would not really help here.)



Luckily most .bst files that support a dedicated URL field also handle URLs in a way that does not require you to add url... or additional commands; like biblatex they expect the raw URL.



The exact handling of the URL with BibTeX depends on the .bst style you use. agsm uses the command harvardurl which you can redefine. Unfortunately, there is no general consensus amongst all .bst as to how URLs are handled. Many .bst files just use url... directly (notably the standard natbib styles and urlbst), a few like agsm have a dedicated command.



natbib's definition of agsm's harvardurl should probably be tweaked a bit to allow for all kinds of URLs.



edit: I originally understood the use of myurl in the MWE as an attempt to uniformly change the URL format for both biblatex and BibTeX styles (possibly independent of other urls displayed in the document). If that was indeed the aim of myurl, you need to know how your .bst files handles URLs and redefine the commands involved accordingly. It would be nigh-impossible to pull this off in a style-agnostic fashion. If, on the other hand, you only intended to fix the undesired output of the biblatex URLs in the MWE and you generally want the URLs to be displayed "normally", then there is no need for murl at all and you can probably just use the styles as they are. See the edit history for the first version of the answer.



documentclassarticle
usepackagefilecontents
defUseBibLaTeX0
usepackage[hyphens]url


ifnumUseBibLaTeX>0
usepackage[backend=biber,style=authoryear]biblatex
addbibresourcejobname.bib
else
usepackagenatbib
renewcommandharvardurl[1]textbfURL: url#1
fi

beginfilecontents*jobname.bib
@misccite1,
title = One Article with a url that has to break both in bibtex and biblatex,
author = Someone NotMe and Someother Me,
year = 2018,
url = http://A-long-URL-that-has-to-break-through-lines-and-biber-has-to-ignore-the-textbackslash url-command,

endfilecontents*

begindocument
nocite*
ifnumUseBibLaTeX>0
printbibliography
else
bibliographystyleagsm
bibliographyjobname
fi
enddocument





share|improve this answer






















  • Thanks, will it will work for more styles in bibtex? (I am going to accept it anyway... but would like to be a little more flexible between styles if possible)
    – koleygr
    55 mins ago










  • @koleygr It depends on the .bst style. For starters, it won't work if the .bst file does not support a url field. The code with harvardurl only works for .bst files that use harvardurl. Depending on the exact code for URLs that your style may use, this would have to be tweaked slightly. Given that there is no universal standard for URLs in .bst files, that is about as general as it gets, sorry.
    – moewe
    51 mins ago











  • Thanks... I am somehow disappointed for this... because the style was just an example and I meant to use this way to have more ways to print the bibliography and not less chances to work... Of course if url doesn't supported it will be ignored and this is not a problem since I will have decided to use the style... I have to change the code (your let) to something supported by my specific bibtex style if any. (Remove the DeclareFieldFormaturl command since doesn't do something useful now . Also myurl doensn's needed since url would be enough... but your point is clear). Thanks again
    – koleygr
    30 mins ago










  • @koleygr Well if you don't want to mess with the output the styles give you by default, you don't need myurl and all the redefinitions. In that case most .bst files with URL support will just work. I thought the whole point of myurl was to be able to manipulate the URL output uniformly for both biblatex and BibTeX?
    – moewe
    28 mins ago










  • @koleygr I think I misunderstood your myurl, see the updated answer, please.
    – moewe
    19 mins 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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
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%2f455698%2fenabling-double-way-for-bibliography-with-url-both-bibtex-and-biblatex-biber%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
5
down vote



accepted










biblatex expects the url field to contain the URL and the URL only. No additional markup like url..., no escaping of special characters, nothing, just the verbose URL.



The problem you are seeing is that Biber applies percent encoding to the URL and this messes up your url... wrapper. (There are ways to get rid of the percent encoding, see biblatex, using space in url doesnt work, How to disable percent-encoding in URLs?, Scandinavian letters in Biblatex URL, but that would not really help here.)



Luckily most .bst files that support a dedicated URL field also handle URLs in a way that does not require you to add url... or additional commands; like biblatex they expect the raw URL.



The exact handling of the URL with BibTeX depends on the .bst style you use. agsm uses the command harvardurl which you can redefine. Unfortunately, there is no general consensus amongst all .bst as to how URLs are handled. Many .bst files just use url... directly (notably the standard natbib styles and urlbst), a few like agsm have a dedicated command.



natbib's definition of agsm's harvardurl should probably be tweaked a bit to allow for all kinds of URLs.



edit: I originally understood the use of myurl in the MWE as an attempt to uniformly change the URL format for both biblatex and BibTeX styles (possibly independent of other urls displayed in the document). If that was indeed the aim of myurl, you need to know how your .bst files handles URLs and redefine the commands involved accordingly. It would be nigh-impossible to pull this off in a style-agnostic fashion. If, on the other hand, you only intended to fix the undesired output of the biblatex URLs in the MWE and you generally want the URLs to be displayed "normally", then there is no need for murl at all and you can probably just use the styles as they are. See the edit history for the first version of the answer.



documentclassarticle
usepackagefilecontents
defUseBibLaTeX0
usepackage[hyphens]url


ifnumUseBibLaTeX>0
usepackage[backend=biber,style=authoryear]biblatex
addbibresourcejobname.bib
else
usepackagenatbib
renewcommandharvardurl[1]textbfURL: url#1
fi

beginfilecontents*jobname.bib
@misccite1,
title = One Article with a url that has to break both in bibtex and biblatex,
author = Someone NotMe and Someother Me,
year = 2018,
url = http://A-long-URL-that-has-to-break-through-lines-and-biber-has-to-ignore-the-textbackslash url-command,

endfilecontents*

begindocument
nocite*
ifnumUseBibLaTeX>0
printbibliography
else
bibliographystyleagsm
bibliographyjobname
fi
enddocument





share|improve this answer






















  • Thanks, will it will work for more styles in bibtex? (I am going to accept it anyway... but would like to be a little more flexible between styles if possible)
    – koleygr
    55 mins ago










  • @koleygr It depends on the .bst style. For starters, it won't work if the .bst file does not support a url field. The code with harvardurl only works for .bst files that use harvardurl. Depending on the exact code for URLs that your style may use, this would have to be tweaked slightly. Given that there is no universal standard for URLs in .bst files, that is about as general as it gets, sorry.
    – moewe
    51 mins ago











  • Thanks... I am somehow disappointed for this... because the style was just an example and I meant to use this way to have more ways to print the bibliography and not less chances to work... Of course if url doesn't supported it will be ignored and this is not a problem since I will have decided to use the style... I have to change the code (your let) to something supported by my specific bibtex style if any. (Remove the DeclareFieldFormaturl command since doesn't do something useful now . Also myurl doensn's needed since url would be enough... but your point is clear). Thanks again
    – koleygr
    30 mins ago










  • @koleygr Well if you don't want to mess with the output the styles give you by default, you don't need myurl and all the redefinitions. In that case most .bst files with URL support will just work. I thought the whole point of myurl was to be able to manipulate the URL output uniformly for both biblatex and BibTeX?
    – moewe
    28 mins ago










  • @koleygr I think I misunderstood your myurl, see the updated answer, please.
    – moewe
    19 mins ago














up vote
5
down vote



accepted










biblatex expects the url field to contain the URL and the URL only. No additional markup like url..., no escaping of special characters, nothing, just the verbose URL.



The problem you are seeing is that Biber applies percent encoding to the URL and this messes up your url... wrapper. (There are ways to get rid of the percent encoding, see biblatex, using space in url doesnt work, How to disable percent-encoding in URLs?, Scandinavian letters in Biblatex URL, but that would not really help here.)



Luckily most .bst files that support a dedicated URL field also handle URLs in a way that does not require you to add url... or additional commands; like biblatex they expect the raw URL.



The exact handling of the URL with BibTeX depends on the .bst style you use. agsm uses the command harvardurl which you can redefine. Unfortunately, there is no general consensus amongst all .bst as to how URLs are handled. Many .bst files just use url... directly (notably the standard natbib styles and urlbst), a few like agsm have a dedicated command.



natbib's definition of agsm's harvardurl should probably be tweaked a bit to allow for all kinds of URLs.



edit: I originally understood the use of myurl in the MWE as an attempt to uniformly change the URL format for both biblatex and BibTeX styles (possibly independent of other urls displayed in the document). If that was indeed the aim of myurl, you need to know how your .bst files handles URLs and redefine the commands involved accordingly. It would be nigh-impossible to pull this off in a style-agnostic fashion. If, on the other hand, you only intended to fix the undesired output of the biblatex URLs in the MWE and you generally want the URLs to be displayed "normally", then there is no need for murl at all and you can probably just use the styles as they are. See the edit history for the first version of the answer.



documentclassarticle
usepackagefilecontents
defUseBibLaTeX0
usepackage[hyphens]url


ifnumUseBibLaTeX>0
usepackage[backend=biber,style=authoryear]biblatex
addbibresourcejobname.bib
else
usepackagenatbib
renewcommandharvardurl[1]textbfURL: url#1
fi

beginfilecontents*jobname.bib
@misccite1,
title = One Article with a url that has to break both in bibtex and biblatex,
author = Someone NotMe and Someother Me,
year = 2018,
url = http://A-long-URL-that-has-to-break-through-lines-and-biber-has-to-ignore-the-textbackslash url-command,

endfilecontents*

begindocument
nocite*
ifnumUseBibLaTeX>0
printbibliography
else
bibliographystyleagsm
bibliographyjobname
fi
enddocument





share|improve this answer






















  • Thanks, will it will work for more styles in bibtex? (I am going to accept it anyway... but would like to be a little more flexible between styles if possible)
    – koleygr
    55 mins ago










  • @koleygr It depends on the .bst style. For starters, it won't work if the .bst file does not support a url field. The code with harvardurl only works for .bst files that use harvardurl. Depending on the exact code for URLs that your style may use, this would have to be tweaked slightly. Given that there is no universal standard for URLs in .bst files, that is about as general as it gets, sorry.
    – moewe
    51 mins ago











  • Thanks... I am somehow disappointed for this... because the style was just an example and I meant to use this way to have more ways to print the bibliography and not less chances to work... Of course if url doesn't supported it will be ignored and this is not a problem since I will have decided to use the style... I have to change the code (your let) to something supported by my specific bibtex style if any. (Remove the DeclareFieldFormaturl command since doesn't do something useful now . Also myurl doensn's needed since url would be enough... but your point is clear). Thanks again
    – koleygr
    30 mins ago










  • @koleygr Well if you don't want to mess with the output the styles give you by default, you don't need myurl and all the redefinitions. In that case most .bst files with URL support will just work. I thought the whole point of myurl was to be able to manipulate the URL output uniformly for both biblatex and BibTeX?
    – moewe
    28 mins ago










  • @koleygr I think I misunderstood your myurl, see the updated answer, please.
    – moewe
    19 mins ago












up vote
5
down vote



accepted







up vote
5
down vote



accepted






biblatex expects the url field to contain the URL and the URL only. No additional markup like url..., no escaping of special characters, nothing, just the verbose URL.



The problem you are seeing is that Biber applies percent encoding to the URL and this messes up your url... wrapper. (There are ways to get rid of the percent encoding, see biblatex, using space in url doesnt work, How to disable percent-encoding in URLs?, Scandinavian letters in Biblatex URL, but that would not really help here.)



Luckily most .bst files that support a dedicated URL field also handle URLs in a way that does not require you to add url... or additional commands; like biblatex they expect the raw URL.



The exact handling of the URL with BibTeX depends on the .bst style you use. agsm uses the command harvardurl which you can redefine. Unfortunately, there is no general consensus amongst all .bst as to how URLs are handled. Many .bst files just use url... directly (notably the standard natbib styles and urlbst), a few like agsm have a dedicated command.



natbib's definition of agsm's harvardurl should probably be tweaked a bit to allow for all kinds of URLs.



edit: I originally understood the use of myurl in the MWE as an attempt to uniformly change the URL format for both biblatex and BibTeX styles (possibly independent of other urls displayed in the document). If that was indeed the aim of myurl, you need to know how your .bst files handles URLs and redefine the commands involved accordingly. It would be nigh-impossible to pull this off in a style-agnostic fashion. If, on the other hand, you only intended to fix the undesired output of the biblatex URLs in the MWE and you generally want the URLs to be displayed "normally", then there is no need for murl at all and you can probably just use the styles as they are. See the edit history for the first version of the answer.



documentclassarticle
usepackagefilecontents
defUseBibLaTeX0
usepackage[hyphens]url


ifnumUseBibLaTeX>0
usepackage[backend=biber,style=authoryear]biblatex
addbibresourcejobname.bib
else
usepackagenatbib
renewcommandharvardurl[1]textbfURL: url#1
fi

beginfilecontents*jobname.bib
@misccite1,
title = One Article with a url that has to break both in bibtex and biblatex,
author = Someone NotMe and Someother Me,
year = 2018,
url = http://A-long-URL-that-has-to-break-through-lines-and-biber-has-to-ignore-the-textbackslash url-command,

endfilecontents*

begindocument
nocite*
ifnumUseBibLaTeX>0
printbibliography
else
bibliographystyleagsm
bibliographyjobname
fi
enddocument





share|improve this answer














biblatex expects the url field to contain the URL and the URL only. No additional markup like url..., no escaping of special characters, nothing, just the verbose URL.



The problem you are seeing is that Biber applies percent encoding to the URL and this messes up your url... wrapper. (There are ways to get rid of the percent encoding, see biblatex, using space in url doesnt work, How to disable percent-encoding in URLs?, Scandinavian letters in Biblatex URL, but that would not really help here.)



Luckily most .bst files that support a dedicated URL field also handle URLs in a way that does not require you to add url... or additional commands; like biblatex they expect the raw URL.



The exact handling of the URL with BibTeX depends on the .bst style you use. agsm uses the command harvardurl which you can redefine. Unfortunately, there is no general consensus amongst all .bst as to how URLs are handled. Many .bst files just use url... directly (notably the standard natbib styles and urlbst), a few like agsm have a dedicated command.



natbib's definition of agsm's harvardurl should probably be tweaked a bit to allow for all kinds of URLs.



edit: I originally understood the use of myurl in the MWE as an attempt to uniformly change the URL format for both biblatex and BibTeX styles (possibly independent of other urls displayed in the document). If that was indeed the aim of myurl, you need to know how your .bst files handles URLs and redefine the commands involved accordingly. It would be nigh-impossible to pull this off in a style-agnostic fashion. If, on the other hand, you only intended to fix the undesired output of the biblatex URLs in the MWE and you generally want the URLs to be displayed "normally", then there is no need for murl at all and you can probably just use the styles as they are. See the edit history for the first version of the answer.



documentclassarticle
usepackagefilecontents
defUseBibLaTeX0
usepackage[hyphens]url


ifnumUseBibLaTeX>0
usepackage[backend=biber,style=authoryear]biblatex
addbibresourcejobname.bib
else
usepackagenatbib
renewcommandharvardurl[1]textbfURL: url#1
fi

beginfilecontents*jobname.bib
@misccite1,
title = One Article with a url that has to break both in bibtex and biblatex,
author = Someone NotMe and Someother Me,
year = 2018,
url = http://A-long-URL-that-has-to-break-through-lines-and-biber-has-to-ignore-the-textbackslash url-command,

endfilecontents*

begindocument
nocite*
ifnumUseBibLaTeX>0
printbibliography
else
bibliographystyleagsm
bibliographyjobname
fi
enddocument






share|improve this answer














share|improve this answer



share|improve this answer








edited 52 secs ago

























answered 1 hour ago









moewe

79.1k797300




79.1k797300











  • Thanks, will it will work for more styles in bibtex? (I am going to accept it anyway... but would like to be a little more flexible between styles if possible)
    – koleygr
    55 mins ago










  • @koleygr It depends on the .bst style. For starters, it won't work if the .bst file does not support a url field. The code with harvardurl only works for .bst files that use harvardurl. Depending on the exact code for URLs that your style may use, this would have to be tweaked slightly. Given that there is no universal standard for URLs in .bst files, that is about as general as it gets, sorry.
    – moewe
    51 mins ago











  • Thanks... I am somehow disappointed for this... because the style was just an example and I meant to use this way to have more ways to print the bibliography and not less chances to work... Of course if url doesn't supported it will be ignored and this is not a problem since I will have decided to use the style... I have to change the code (your let) to something supported by my specific bibtex style if any. (Remove the DeclareFieldFormaturl command since doesn't do something useful now . Also myurl doensn's needed since url would be enough... but your point is clear). Thanks again
    – koleygr
    30 mins ago










  • @koleygr Well if you don't want to mess with the output the styles give you by default, you don't need myurl and all the redefinitions. In that case most .bst files with URL support will just work. I thought the whole point of myurl was to be able to manipulate the URL output uniformly for both biblatex and BibTeX?
    – moewe
    28 mins ago










  • @koleygr I think I misunderstood your myurl, see the updated answer, please.
    – moewe
    19 mins ago
















  • Thanks, will it will work for more styles in bibtex? (I am going to accept it anyway... but would like to be a little more flexible between styles if possible)
    – koleygr
    55 mins ago










  • @koleygr It depends on the .bst style. For starters, it won't work if the .bst file does not support a url field. The code with harvardurl only works for .bst files that use harvardurl. Depending on the exact code for URLs that your style may use, this would have to be tweaked slightly. Given that there is no universal standard for URLs in .bst files, that is about as general as it gets, sorry.
    – moewe
    51 mins ago











  • Thanks... I am somehow disappointed for this... because the style was just an example and I meant to use this way to have more ways to print the bibliography and not less chances to work... Of course if url doesn't supported it will be ignored and this is not a problem since I will have decided to use the style... I have to change the code (your let) to something supported by my specific bibtex style if any. (Remove the DeclareFieldFormaturl command since doesn't do something useful now . Also myurl doensn's needed since url would be enough... but your point is clear). Thanks again
    – koleygr
    30 mins ago










  • @koleygr Well if you don't want to mess with the output the styles give you by default, you don't need myurl and all the redefinitions. In that case most .bst files with URL support will just work. I thought the whole point of myurl was to be able to manipulate the URL output uniformly for both biblatex and BibTeX?
    – moewe
    28 mins ago










  • @koleygr I think I misunderstood your myurl, see the updated answer, please.
    – moewe
    19 mins ago















Thanks, will it will work for more styles in bibtex? (I am going to accept it anyway... but would like to be a little more flexible between styles if possible)
– koleygr
55 mins ago




Thanks, will it will work for more styles in bibtex? (I am going to accept it anyway... but would like to be a little more flexible between styles if possible)
– koleygr
55 mins ago












@koleygr It depends on the .bst style. For starters, it won't work if the .bst file does not support a url field. The code with harvardurl only works for .bst files that use harvardurl. Depending on the exact code for URLs that your style may use, this would have to be tweaked slightly. Given that there is no universal standard for URLs in .bst files, that is about as general as it gets, sorry.
– moewe
51 mins ago





@koleygr It depends on the .bst style. For starters, it won't work if the .bst file does not support a url field. The code with harvardurl only works for .bst files that use harvardurl. Depending on the exact code for URLs that your style may use, this would have to be tweaked slightly. Given that there is no universal standard for URLs in .bst files, that is about as general as it gets, sorry.
– moewe
51 mins ago













Thanks... I am somehow disappointed for this... because the style was just an example and I meant to use this way to have more ways to print the bibliography and not less chances to work... Of course if url doesn't supported it will be ignored and this is not a problem since I will have decided to use the style... I have to change the code (your let) to something supported by my specific bibtex style if any. (Remove the DeclareFieldFormaturl command since doesn't do something useful now . Also myurl doensn's needed since url would be enough... but your point is clear). Thanks again
– koleygr
30 mins ago




Thanks... I am somehow disappointed for this... because the style was just an example and I meant to use this way to have more ways to print the bibliography and not less chances to work... Of course if url doesn't supported it will be ignored and this is not a problem since I will have decided to use the style... I have to change the code (your let) to something supported by my specific bibtex style if any. (Remove the DeclareFieldFormaturl command since doesn't do something useful now . Also myurl doensn's needed since url would be enough... but your point is clear). Thanks again
– koleygr
30 mins ago












@koleygr Well if you don't want to mess with the output the styles give you by default, you don't need myurl and all the redefinitions. In that case most .bst files with URL support will just work. I thought the whole point of myurl was to be able to manipulate the URL output uniformly for both biblatex and BibTeX?
– moewe
28 mins ago




@koleygr Well if you don't want to mess with the output the styles give you by default, you don't need myurl and all the redefinitions. In that case most .bst files with URL support will just work. I thought the whole point of myurl was to be able to manipulate the URL output uniformly for both biblatex and BibTeX?
– moewe
28 mins ago












@koleygr I think I misunderstood your myurl, see the updated answer, please.
– moewe
19 mins ago




@koleygr I think I misunderstood your myurl, see the updated answer, please.
– moewe
19 mins ago

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f455698%2fenabling-double-way-for-bibliography-with-url-both-bibtex-and-biblatex-biber%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

What does second last employer means? [closed]

Installing NextGIS Connect into QGIS 3?

One-line joke