Biblatex - numeric-comp - suppress doi and url for journals, unless the article has no page numers

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}

\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},
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}


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}

\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},
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}


Second solution based on keywords

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

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

\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},
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}

• I agree about changing the @misc type. My problem is that I am generating my biblatex file from Mendeley which synchronises it with its library and overwrites all changes I make. It also classifies patents as @misc instead of @patent making it less straightforward to simply reclassify all @misc. The doi suggestions is good though! – P-M Jul 20 '17 at 11:55
• @P-M Is there any way to differentiate between online misc entries and patent misc entries? Maybe some field which is only ever filled for one of them? Can you add both types to your MWE? – user36296 Jul 20 '17 at 11:59
• It seems to contain a publisher field which I would imagine won't exist for a webpage. I have added an example. One approach I could think of would be to manually copy the entries in question to a separate file where I can define them correctly and then import two .bib files. – P-M Jul 20 '17 at 12:06
• @P-M Please see my updated answer. If the differentiation between misc entries with/without publisher turns out to be not enough you could use the keywords field to enter the type (website/patent) in menedeley and then use a this information to filter between the types instead of \ifentrytype – user36296 Jul 20 '17 at 12:19
• That sounds like a great idea. Could you edit the answer to show how I would do that? – P-M Jul 20 '17 at 12:40