1

I am using apacite with natbib and have all my literature in Mendeley.

I just found how to supress the URL in the bibliography when DOI is present (Linebreak in url). However, I`d like to supress both URL and DOI for all entries, except for web pages - there the URL and the last revised fields should be shown. I am not sure how to change the code from the example above (Linkebreak in url) or how to do that at all - any ideas?

MWE:

\documentclass{article}
\usepackage[natbibapa]{apacite}
\usepackage{etoolbox}
\usepackage{environ}
\newtoggle{bibdoi}
\newtoggle{biburl}
\makeatletter
\undef{\APACrefURL}
\undef{\endAPACrefURL}
\undef{\APACrefDOI}
\undef{\endAPACrefDOI}
\long\def\collect@url#1{\global\def\bib@url{#1}}
\long\def\collect@doi#1{\global\def\bib@doi{#1}}

\newenvironment{APACrefURL}{\global\toggletrue{biburl}\Collect@Body  \collect@url}{\unskip\unskip}

\newenvironment{APACrefDOI}{\global\toggletrue{bibdoi}\Collect@Body\collect@doi}{}

\AtBeginEnvironment{thebibliography}{

 \pretocmd{\PrintBackRefs}{%

  \iftoggle{bibdoi}

    {\iftoggle{biburl}{\unskip\unskip}{}}

    {\iftoggle{biburl}{\unskip\unskip }{}}

  \togglefalse{bibdoi}\togglefalse{biburl}%

  }{}{}

}

\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
  @misc{PwC2013,
        author = {PwC},
        mendeley-groups = {Sharing},
        title = {{The sharing economy - sizing the revenue opportunity}},
        url = {http://www.pwc.co.uk/issues/megatrends/collisions/sharingeconomy/the-sharing-economy-sizing-the-revenue-opportunity.html},
        urldate = {2015-10-29},
        year = {2013}
  }
\end{filecontents*}

\begin{document}
\citet{PwC2013}
\bibliographystyle{apacite}
\bibliography{\jobname}
\end{document}

Wit this code I can get rid of all URLs and DOIs, however, I need them for the web page entries (here misc).

  • Welcome to tex.stackexchange!. Could you please provide us a minimal example (MWE), that we could compile and work on? – Clément Nov 30 '15 at 15:16
  • If I copy and paste your code in a tex file and tries to compile it, I get multiple errors: what is the class, where begins the document? Also, learn to format your code by prefixing it with 4 spaces, so that it is displayed as code block. – Clément Nov 30 '15 at 16:06
  • Do you use the misc field only for webpages? Is switching to biblatex an option? – Clément Nov 30 '15 at 16:30
  • @Clément, I use Mendeleys web page field, however, in bibtex it seems to be "transformed" to misc. Biblatex seems to be more complicated, so Id be glad to stick to bibtex. – latexQ Nov 30 '15 at 16:58
  • anyone ideas? I still encounter the problem and cannot figure out how to solve it. – latexQ Apr 8 '16 at 10:14

Your Answer

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

Browse other questions tagged or ask your own question.