[Tex/LaTex] Biblatex – numeric-comp – suppress doi and url for journals, unless the article has no page numers

biberbiblatexbibliographies

I am using the numeric-comp citation style with Biber and biblatex. The problem that I have is that it by default displays URLs and DOIs for all journal articles in my bibliography. I don't want that. Turning off the DOIs is straightforwar by setting \usepackage[style=numeric-comp,sorting=none,backend=biber,isbn=false,doi=false]{biblatex}.

This however seems to mean that for those articles for which there are no page and volume numbers it does not add the DOI back in, which I thought is what it ought to do automatically.

Getting rid of the URLs is more complicated. If I simply add a url=false to the settings it does remove the URLs for journals, but it also removes URLs from all websites that I cite which it definitely should not be doing.

I am aware that one approach I could be using would be to simply delete all URLs for all journal articles in my bibtex file as proposed e.g. here but that would mean that in cases where no page numbers or DOIs are available I will then miss the information on URLs too (I have one or two articles in my collection which are classed as journal but can only be accessed via a URL).

Thus my questions:

1) Why does biblatex not reinsert the DOIs where they are required when I disable them? How can I get it to do so?

2) Why does url=false also disable the urls in websites? I was under the impression that my manual settings would be overridden automatically where required.

EDIT: I have inserted an MWE below as requested. One problem I could see with it here is that Mendeley seems to save a website as "misc" instead of "online". But that doesn't explain the problem with the dois yet. Mendeley also exports patents incorrectly meaning that websites and patents get lumped into the same category (see Sato1986 in the biblatex file).

\documentclass[a4paper]{article}
\usepackage[style=numeric-comp,sorting=none,backend=biber,isbn=false,date=year,doi=false,url=false]{biblatex}
\addbibresource{\jobname.bib}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{Lapkin2017,
author = {Lapkin, Alexei A. and Heer, Parminder K and Jacob, P.-M. and Hutchby, Marc and Cunningham, William and Bull, S. D. and Davidson, Matthew G},
doi = {10.1039/C7FD00073A},
file = {:D$\backslash$:/pmj27/Mendeley/Library/Lapkin et al. - 2017 - Automation of route identification and optimisation based on data-mining and chemical intuition.pdf:pdf},
issn = {1359-6640},
journal = {Faraday Discuss.},
keywords = {chemoinformatics,network of organic chemistry,networks,shortest path,shortest path criteria},
mendeley-tags = {chemoinformatics,network of organic chemistry,networks,shortest path,shortest path criteria},
title = {{Automation of route identification and optimisation based on data-mining and chemical intuition}},
year = {2017}
}
@article{Gibb2013,
author = {Gibb, Bruce C},
doi = {10.1038/nchem.1604},
file = {:D$\backslash$:/pmj27/Mendeley/Library/Gibb - 2013 - Big (chemistry) data.pdf:pdf},
issn = {1755-4330},
journal = {Nature Chemistry},
keywords = {network of organic chemistry},
mendeley-tags = {network of organic chemistry},
month = {mar},
number = {4},
pages = {248--249},
pmid = {23511403},
publisher = {Nature Publishing Group},
title = {{Big (chemistry) data}},
url = {http://www.ncbi.nlm.nih.gov/pubmed/23511403 http://www.nature.com/doifinder/10.1038/nchem.1604},
volume = {5},
year = {2013}
}
@misc{AirLiquide2013,
author = {{Air Liquide}},
keywords = {exergy analysis},
mendeley-tags = {exergy analysis},
title = {{Gas Encyclopedia - Air Liquide}},
url = {http://encyclopedia.airliquide.com/encyclopedia.asp?LanguageID=11},
urldate = {2015-11-11},
year = {2013}
}
@misc{Sato1986,
author = {Sato, H and Ishii, N and Hirose, K},
file = {:D$\backslash$:/pmj27/Mendeley/Library/Sato, Ishii, Hirose - 1986 - Selective catalytic dealkylation of 1, 4-dialkylbenzenes.pdf:pdf},
keywords = {terpenes},
mendeley-tags = {terpenes},
publisher = {European Patent Office},
title = {{Selective catalytic dealkylation of 1, 4-dialkylbenzenes}},
url = {http://www.freepatentsonline.com/EP0231569.html},
year = {1986}
}
\end{filecontents}
\begin{document}

\cite{Lapkin2017} \cite{Gibb2013} \cite{AirLiquide2013} \cite{Sato1986}

\printbibliography
\end{document}

Best Answer

To retain the doi for entries which don't have pages, you could do it the other way round and only remove the doi for entried that have pages.

In the same way you could clear the url for all non-misc entries (if menedeley would not interfere using url=false and changing @misc to @online would be the better way).

\documentclass[a4paper]{article}
\usepackage[style=numeric-comp,sorting=none,backend=biber,isbn=false,date=year]{biblatex}
\addbibresource{\jobname.bib}

\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@article{Lapkin2017,
author = {Lapkin, Alexei A. and Heer, Parminder K and Jacob, P.-M. and Hutchby, Marc and Cunningham, William and Bull, S. D. and Davidson, Matthew G},
doi = {10.1039/C7FD00073A},
file = {:D$\backslash$:/pmj27/Mendeley/Library/Lapkin et al. - 2017 - Automation of route identification and optimisation based on data-mining and chemical intuition.pdf:pdf},
issn = {1359-6640},
journal = {Faraday Discuss.},
keywords = {chemoinformatics,network of organic chemistry,networks,shortest path,shortest path criteria},
mendeley-tags = {chemoinformatics,network of organic chemistry,networks,shortest path,shortest path criteria},
title = {{Automation of route identification and optimisation based on data-mining and chemical intuition}},
year = {2017}
}
@article{Gibb2013,
author = {Gibb, Bruce C},
doi = {10.1038/nchem.1604},
file = {:D$\backslash$:/pmj27/Mendeley/Library/Gibb - 2013 - Big (chemistry) data.pdf:pdf},
issn = {1755-4330},
journal = {Nature Chemistry},
keywords = {network of organic chemistry},
mendeley-tags = {network of organic chemistry},
month = {mar},
number = {4},
pages = {248--249},
pmid = {23511403},
publisher = {Nature Publishing Group},
title = {{Big (chemistry) data}},
url = {http://www.ncbi.nlm.nih.gov/pubmed/23511403 http://www.nature.com/doifinder/10.1038/nchem.1604},
volume = {5},
year = {2013}
}
@misc{AirLiquide2013,
author = {{Air Liquide}},
keywords = {exergy analysis},
mendeley-tags = {exergy analysis},
title = {{Gas Encyclopedia - Air Liquide}},
url = {http://encyclopedia.airliquide.com/encyclopedia.asp?LanguageID=11},
urldate = {2015-11-11},
year = {2013}
}
@misc{Sato1986,
author = {Sato, H and Ishii, N and Hirose, K},
file = {:D$\backslash$:/pmj27/Mendeley/Library/Sato, Ishii, Hirose - 1986 - Selective catalytic dealkylation of 1, 4-dialkylbenzenes.pdf:pdf},
keywords = {terpenes},
mendeley-tags = {terpenes},
publisher = {European Patent Office},
title = {{Selective catalytic dealkylation of 1, 4-dialkylbenzenes}},
url = {http://www.freepatentsonline.com/EP0231569.html},
year = {1986}
}
\end{filecontents*}


\AtEveryBibitem{
    \iffieldundef{pages}{}{\clearfield{doi}}
    \ifentrytype{misc}{\iflistundef{publisher}{}{\clearfield{url}}}{\clearfield{url}}
}


\begin{document}


\cite{Lapkin2017} \cite{Gibb2013} \cite{AirLiquide2013} \cite{Sato1986}

\printbibliography
\end{document}

enter image description here


Second solution based on keywords

This assumes that for all your patents, you edit the keyword field in Mendeley

enter image description here

\documentclass[a4paper]{article}
\usepackage[style=numeric-comp,sorting=none,backend=biber,isbn=false,date=year]{biblatex}
\addbibresource{\jobname.bib}

\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@article{Lapkin2017,
author = {Lapkin, Alexei A. and Heer, Parminder K and Jacob, P.-M. and Hutchby, Marc and Cunningham, William and Bull, S. D. and Davidson, Matthew G},
doi = {10.1039/C7FD00073A},
file = {:D$\backslash$:/pmj27/Mendeley/Library/Lapkin et al. - 2017 - Automation of route identification and optimisation based on data-mining and chemical intuition.pdf:pdf},
issn = {1359-6640},
journal = {Faraday Discuss.},
keywords = {chemoinformatics,network of organic chemistry,networks,shortest path,shortest path criteria},
mendeley-tags = {chemoinformatics,network of organic chemistry,networks,shortest path,shortest path criteria},
title = {{Automation of route identification and optimisation based on data-mining and chemical intuition}},
year = {2017}
}
@article{Gibb2013,
author = {Gibb, Bruce C},
doi = {10.1038/nchem.1604},
file = {:D$\backslash$:/pmj27/Mendeley/Library/Gibb - 2013 - Big (chemistry) data.pdf:pdf},
issn = {1755-4330},
journal = {Nature Chemistry},
keywords = {network of organic chemistry},
mendeley-tags = {network of organic chemistry},
month = {mar},
number = {4},
pages = {248--249},
pmid = {23511403},
publisher = {Nature Publishing Group},
title = {{Big (chemistry) data}},
url = {http://www.ncbi.nlm.nih.gov/pubmed/23511403 http://www.nature.com/doifinder/10.1038/nchem.1604},
volume = {5},
year = {2013}
}
@misc{AirLiquide2013,
author = {{Air Liquide}},
keywords = {exergy analysis},
mendeley-tags = {exergy analysis},
title = {{Gas Encyclopedia - Air Liquide}},
url = {http://encyclopedia.airliquide.com/encyclopedia.asp?LanguageID=11},
urldate = {2015-11-11},
year = {2013},
keywords = {website}
}
@misc{Sato1986,
author = {Sato, H and Ishii, N and Hirose, K},
file = {:D$\backslash$:/pmj27/Mendeley/Library/Sato, Ishii, Hirose - 1986 - Selective catalytic dealkylation of 1, 4-dialkylbenzenes.pdf:pdf},
keywords = {patent},
mendeley-tags = {terpenes},
publisher = {European Patent Office},
title = {{Selective catalytic dealkylation of 1, 4-dialkylbenzenes}},
url = {http://www.freepatentsonline.com/EP0231569.html},
year = {1986}
}
\end{filecontents*}


\AtEveryBibitem{
    \iffieldundef{pages}{}{\clearfield{doi}}
    \ifentrytype{misc}{\iffieldequalstr{keywords}{patent}{\clearfield{url}}{}}{\clearfield{url}}
}


\begin{document}


\cite{Lapkin2017} \cite{Gibb2013} \cite{AirLiquide2013} \cite{Sato1986}

\printbibliography
\end{document}