6

I'm using BibTeX (requirement of the journal I'm submitting to), and I'm referencing mostly journal articles, but also one blog post. I would like to hid the urls in the references list, but only for the journal articles. The url should still display for the blog post. Is this possible without removing the URLs from the .bib file?

1
  • Presumably you have to use a fixed BibTeX style (.bst file)? The usual way to handle things is to select printing of fields in the .bst file, but that's not possible if you have to use one and can't edit it.
    – Joseph Wright
    Sep 18, 2013 at 6:04

1 Answer 1

1

Here is an hack if there is only one blog, and key for the blog is known.

This solution also assumes:

1) that the url bibtex field is rendered by \url{<field>}.

2) natbib or other bibliography managers modifying (and adding arguments) to \bibitem` are not used (though, in some cases this is easy to fix).

\documentclass{article}

\usepackage{xpatch}
\usepackage{etoolbox}
\usepackage{filecontents}
\usepackage{url}

\begin{filecontents}{\jobname.bbl}
\begin{thebibliography}{1}
\bibitem{abc}
Author.
\newblock Title.
\newblock {\em Journal}, 2013. \url{http://article.example.com}

\bibitem{cde}
blogAuthot.
\newblock blogtitle. \url{blog.examnple.com}
\end{thebibliography}
\end{filecontents}

\let\oldurl\url
\providetoggle{blog}
\renewcommand{\url}[1]{\iftoggle{blog}{\oldurl{#1}}{}}

\xapptocmd{\@bibitem}{
  \ifstrequal{#1}{cde}
    {\toggletrue{blog}}
    {\togglefalse{blog}}}
    {}
    {}
\begin{document}

This is a reference to an article \cite{abc}, this a reference to a blog \cite{cde}.

%\bibliographystyle{<style creating bbl with \url>}
\bibliography{\jobname}

\end{document}

enter image description here

The idea is to have a toggle for the blog, and based on this \url is define to essentially gobble its content. The toggle is set to true based on the content of the bibtex key for the blog (cde in the example above). It is possible to extend to above to a list of values.

1
  • I'd prefer \renewcommand{\url}{\iftoggle{blog}{\oldurl}{\@gobble} (requires the usual \makeatletter and \makeatother) so the argument to \url is not untimely read and tokenized.
    – egreg
    Sep 18, 2013 at 9:31

You must log in to answer this question.

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