4

I'm trying to have titles link to articles in bibliography entries by putting a \href around them that with the link. However, when I do this, it results in words in the title not getting properly put in lower case. An obvious solution would be to just put the titles in the bib file with the capitalization called for by the bibliography style, but I was wondering if there's a simple way to make BibTeX format the titles as it does normally without having to fix the titles by hand.

MWE:

\documentclass{article}
\usepackage{natbib}
\usepackage{hyperref}

\begin{filecontents}{my.bib}
    @unpublished{Sample,
        Author = {Sample},
        Title = {\href{}{A Title in Title Case}},
        Year = {0000},
        Note = {Note}
    }
\end{filecontents}

\begin{document}
    \bibliographystyle{plain}
    \nocite{Sample}
    \bibliography{my}
\end{document}

This produces undesired capitalization:

[1] Sample. A Title in Title Case. Note, 0000.

Leaving out the \href in the title produces the desired capitalization:

[1] Sample. A title in title case. Note, 0000.

4

You can fix your problem my not directly writing \href: You provide a link to the entry, so semantically it belongs into the Url field:

@unpublished{Sample,
    Author = {Sample},
    Title = {A Title in Title Case},
    Year = {0000},
    Url = {...},
    Note = {Note}
}

Then you only need a \bibliographystyle which makes the title a link to the url. You can create this yourself: In your TeX installation you can find the file with the plain style, plain.bst (You can also find it on CTAN). Copy this into the directory of your TeX file under the name link.bst. This will be our starting point.

At first, you have to add the url field: At the top of the file link.bst you find a list starting with

ENTRY
  { address
    author

Below type, add a line

    url

Now BibTeX knows about url, but ignores the field. To add the link, search the block

FUNCTION {format.title}
{ title empty$
    { "" }
    { title "t" change.case$ }
  if$
}

This block is responsible for showing the title. Replace it by

FUNCTION {format.title}
{ title empty$
    { "" }
    { title "t" change.case$
      url empty$
        { }
        { "\href{" url * "}{" * swap$ * "}" * }
      if$
    }
  if$
}

This will put \href{<url>}{...} around the title if a Url was given.

If you save the changes you can use \bibliographystyle{link} to use the new style. In your MWE, you also have to replace

\usepackage{natbib}

by

\usepackage[numbers]{natbib}

because link uses numbers as references. This is inherited from plain. A style like plainnat can be used as the base instead to use natbib like Author-Year references instead.

Example:

\documentclass{article}
\usepackage[numbers]{natbib}
\usepackage{hyperref}

\begin{filecontents}{my.bib}
    @unpublished{Sample,
        Author = {Sample},
        Title = {A Title in Title Case},
        Url = {http://eyample.tld/},
        Year = {0000},
        Note = {Note}
    }
\end{filecontents}

\begin{document}
    \bibliographystyle{link}
    \nocite{Sample}
    \bibliography{my}
\end{document}

enter image description here

Your Answer

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

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