1

I am using Zotero + Better BibTex and using the biblatex package to generate a bibliography in APA citation style. I want to exclude url and urldate from academic journal @articles but retain them for newspaper @articles. I have been successful in suppressing urls from ALL articles using the code found here, but I do not see how to add entrysubtype fields to items in Zotero so that I can exclude urls from academic articles alone. Is there a way to enter entrysubtype in Zotero, or is there some other LaTex hack I can use based on an existing @article field?

4

2 Answers 2

2

If you use entrysubtype = {newspaper} for those @articles from a newspaper,

@article{frie2002,
  author  = {Jonathan Friedland},
  title   = {Across the Divide},
  journal = {Guardian}, 
  pages   = {10-11},
  date    = {2002-01-15},
  entrysubtype = {newspaper},
  url     = {https://www.theguardian.com/uk},
  urldate = {2016-09-16},
}

you only need

\AtEveryBibitem{%
  \ifboolexpr{test {\ifentrytype{article}} and not test {\iffieldequalstr{entrysubtype}{newspaper}}}
    {\clearfield{url}%
     \clearfield{urlyear}}
    {}%
}

to delete the url and urldate for non-newspaper @articles.

biblatex-apa, however, also has a @newsarticle entry type

@newsarticle{frie2002,
  author    = {Jonathan Friedland},
  title     = {Across the Divide},
  newspaper = {Guardian}, 
  pages     = {10-11},
  date      = {2002-01-15},
  url       = {https://www.theguardian.com/uk},
  urldate   = {2016-09-16},
}

in which case you want

\AtEveryBibitem{%
  \ifentrytype{newsarticle}
    {\clearfield{url}%
     \clearfield{urlyear}}
    {}%
}
2
  • Where exactly has the \AtEveryBibitem stuff to be included? in the tex file I suppose, but where exactly? in the preamble? Before \addbibresource, after it? somewhere else?
    – helt
    Jun 22, 2018 at 11:20
  • 1
    @helt In the preamble after biblatex has been loaded.
    – moewe
    Jun 22, 2018 at 11:28
0

You can keep all the info about your references intact, copy them from Zotero to your document and still be able to remove unnecessary fields in a reference list.

biblatex has an option to declare maps, which formats items that appear in the reference. Both groups of types or an individual type can be included in mapping. This is explained in Dynamic Modification of Data (see p. 199 of documentation). Personally, I use it for removing urls but I think you can do much more.

In solution below, URL's appear only in online-like reference types, hence I declared the following mapping

\DeclareSourcemap{%
  \maps{%
    % remove URLs for non-online types
    \map{%
      \pernottype{www}
      \pernottype{online}
      % Do not show urls, eprints, and urldates
      \step[fieldset=url, null]
      \step[fieldset=urldate, null]
      \step[fieldset=eprint, null]
    }%
  }%
}

This is the output:

enter image description here

Observe both the article and the book entries still contain url.


The full code

\begin{filecontents*}[overwrite]{example.bib}
@article{frie2002,
    author  = {Jonathan Friedland},
    title   = {Across the Divide},
    journal = {Guardian}, 
    pages   = {10-11},
    date    = {2002-01-15},
    entrysubtype = {newspaper},
    url     = {https://www.theguardian.com/uk},
    urldate = {2016-09-16},
}
@book{ref:murphy2012,
  title = {Machine Learning: A Probabilistic Perspective},
  author = {Murphy, Kevin P.},
  date = {2012},
  series = {Adaptive {{Computation}} and {{Machine Learning}} Series},
  publisher = {{The MIT Press}},
  abstract = {A comprehensive introduction to machine learning that uses probabilistic models and inference as a unifying approach.},
  isbn = {978-0-262-01802-9},
  url = {http://www.example.url.address},
  file = {/home/ziko/Documents/research/papers/pdfs/Murphy/2012/murphy_2012_machine learning.pdf}
}
@www{GoogleWWW,
  title        = {Google website},
  author       = {Google},
  url = {https://www.google,com},
  year         = 2022,
  note         = {Accessed:2022-07-23},
}
@online{CitekeyMiscAudio,
  title        = {Audio: The 'Other' Red Planet},
  author       = {NASA},
  url = {https://www.nasa.gov/nh/pluto-the-other-red-planet},
  year         = 2015,
  note         = {Accessed: 2018-12-06},
}
@online{CitekeyMiscVideo,
  title        = {Video: The 'Other' Red Planet},
  author       = {NASA},
  url = {https://www.nasa.gov/nh/pluto-the-other-red-planet},
  year         = 2015,
  note         = {Accessed: 2018-12-06},
}
\end{filecontents*}
%%%
\documentclass{article}
\usepackage[backend=biber,style=numeric]{biblatex}
    \addbibresource{example.bib}
    \DeclareSourcemap{%
      \maps{%
        \map{%
          % remove URLs from non-internet types
          \pernottype{www}
          \pernottype{online}
          % Do not show urls, eprints, and urldates
          \step[fieldset=url, null]
          \step[fieldset=urldate, null]
          \step[fieldset=eprint, null]
        }%
      }%
    }
\usepackage[colorlinks]{hyperref}


\begin{document}
\nocite{*}
\printbibliography[title=References]
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .