Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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 '13 at 6:04

1 Answer 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.

share|improve this answer
    
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 '13 at 9:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.