I am trying to make a document to accept both bibtex
and biblatex
(during different compilations of course) and I have a problem because:
- In
bibtex
I have to add\url
command inside every url (really many entries) - 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:
\documentclass{article}
\usepackage{filecontents}
% \UseBibLaTex is a variable that if is less than 1 the document
% will have to compiled with `bibTeX`... else with biber
\def\UseBibLaTeX{0}
% ``url'' package is used in order to make LaTeX to break the urls
% in places like the bibliography combined with the next (upcoming)
% command
%\usepackage{breakurl}
\usepackage[hyphens]{url}
\Urlmuskip=0mu plus 1mu
\ifnum\UseBibLaTeX>0
\usepackage[backend=biber,style=authoryear]{biblatex}
\newcommand\myurl[1]{#1}
\DeclareFieldFormat{url}{{\footnotesize URL:}\space%\expandafter%\noexpand
\myurl{#1}}
\addbibresource{myBib.bib}
\else
% ``natbib'' package offers the bigger ammount possibilities in bibliography
% formating
\let\myurl\url
\usepackage{natbib}
\fi
\begin{filecontents*}{myBib.bib}
@Article{cite1,
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={\url{http://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}
}
\end{filecontents*}
\title{Double Functionality about Bibliography}
\author{Konstantinos Leledakis}
\date{October 2018}
\begin{document}
\maketitle
\nocite{*}
\ifnum\UseBibLaTeX>0
\printbibliography
\else
\bibliographystyle{agsm}
\begin{sloppypar}
\bibliography{myBib}
\end{sloppypar}
\fi
\end{document}
The output of the above code, is as expected... but if I change
the command \def\UseBibLaTeX{0}
to \def\UseBibLaTeX{1}
I get (an expected as a noob about biber but...) unwanted result:
Already tried some things like \noexpand
or \expandafter
that are commented in my code but could not make it work as I wanted.
biblatex
is concerned theurl
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 Oct 18 '18 at 14:40bibtex
way (and adding this command to every url field autamaticaly) ifbiblatex
way can not adjusted. I tried with changes inbiblatex
first because I thought is more powerful to handle such situations – koleygr Oct 18 '18 at 14:46\url
command) without changes... But if not posible, I am going to add them as a note – koleygr Oct 18 '18 at 14:55