2

This question is probably a home-run for people that are more into the workings of biblatex than me... Anyway, I want to achieve what has been solved here and here, but with using biblatex-chicago instead of biblatex. That means the URL should be suppressed whenever a DOI is present in the reference. Note: In the original questions it was the other way round.

The MWE of karlkoeller will not work as soon as I replace biblatex:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[backend=biber]{biblatex-chicago}

\addbibresource{\jobname.bib}

\renewbibmacro*{doi+eprint+url}{%
  \iftoggle{bbx:doi}
    {\iffieldundef{url}{\printfield{doi}}{}}
    {}%
  \newunit\newblock
  \iftoggle{bbx:eprint}
    {\usebibmacro{eprint}}
    {}%
  \newunit\newblock
  \iftoggle{bbx:url}
    {\usebibmacro{url+urldate}}
    {}}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{kastenholz1,
  hyphenation = {american},
  author = {Kastenholz, M. A. and H{\"u}nenberger, Philippe H.},
  indextitle = {Computation of ionic solvation free energies},
  title = {Computation of methodology\hyphen independent ionic solvation free
    energies from molecular simulations},
  subtitle = {I. The electrostatic potential in molecular liquids},
  journaltitle = jchph,
  volume = {124},
  eid = {124106},
  date = {2006},
  url = {http://dx.doi.org/10.1063/1.2172593},
  urldate = {2006-10-01},
  doi = {10.1063/1.2172593},
}
@article{kastenholz2,
  hyphenation = {american},
  author = {Kastenholz, M. A. and H{\"u}nenberger, Philippe H.},
  indextitle = {Computation of ionic solvation free energies},
  title = {Computation of methodology\hyphen independent ionic solvation free
    energies from molecular simulations},
  subtitle = {I. The electrostatic potential in molecular liquids},
  journaltitle = jchph,
  volume = {124},
  eid = {124106},
  date = {2006},
  doi = {10.1063/1.2172593},
}
\end{filecontents}


\begin{document}
  \nocite{*}
  \printbibliography
\end{document}

Output:

not good

Who can help, please?

3

Unless I misunderstand the question, wouldn't adding the option

\usepackage[doi=only]{biblatex-chicago}

or

\usepackage[url=false]{biblatex-chicago}

work (the latter would suppress all URLs)? See 4.4.2 in the biblatex-chicago documentation.

  • Thanks. The idea was to suppress the URL only if a DOI is present. – n1000 Dec 12 '18 at 20:16
  • Yes, the 'doi=only' option should do that. Just tested it; works here. – zoned post meridiem Dec 12 '18 at 20:36
  • sorry. cannot test right now. and it still shows the url if no doi is present? sounds good. – n1000 Dec 12 '18 at 20:39
  • It should. Let me know if it doesn't. – zoned post meridiem Dec 12 '18 at 20:52
  • By the way, please accept answer as correct if it works for you. It helps others find/identify the solution when they have the same problem. – zoned post meridiem Apr 3 at 19:16
3

You can patch the two macros responsible for printing the doi and the url to clear the url field if there is a doi defined:

\usepackage{biblatex-chicago}
\usepackage{xpatch}

% patch macro used in bibliography
\xpretobibmacro{bib+doi+url}
  {\iffieldundef{doi}
     {}
     {\clearfield{url}}}
  {}{}

% patch macro used in notes
\xpretobibmacro{cite+doi+url}
  {\iffieldundef{doi}
     {}
     {\clearfield{url}}}
  {}{}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.