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 am trying to make a hyperlink in my bibliography referring the doi-url. The url begins with journal name and ends with the pages. Do to this I am using the code provided by Mateus Araújo in hyperlinks in biblatex. Unfortunately this also changes the style. For example, a normal reference looks likes this

enter image description here

But after adding the code do make the doi-hyperlink, it adds a dot after year and starts with a an uppercase letter.

enter image description here

I would like to remove the dot and start with a lowercase letter, but don't know how do that.

Here is a the code:

\documentclass{article}
\usepackage[backref=true]{biblatex}
\usepackage[colorlinks]{hyperref}
\bibliography{biblatex-examples}

\ExecuteBibliographyOptions{doi=false}
\DeclareFieldFormat{doilink}{
\iffieldundef{doi}{#1}
{\href{http://dx.doi.org/\thefield{doi}}{#1}}}

\DeclareBibliographyDriver{article}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{bytranslator+others}%
  \newunit\newblock
  \printfield{version}%
  \newunit\newblock
  \usebibmacro{in:}%
  \href{http://dx.doi.org/\thefield{doi}}{%
  \usebibmacro{journal+issuetitle}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \usebibmacro{note+pages}}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
   {\printfield{issn}}
   {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}
  }

\begin{document}
\cite{kastenholz}
\printbibliography
\end{document}
share|improve this question
    
You might be able to rephrase your question title so that it matches your questions better. –  N.N. Sep 7 '11 at 10:05
    
I hope the new title makes it clearer –  maetra Sep 7 '11 at 11:20
add comment

1 Answer

up vote 5 down vote accepted

In the linked question is used another bibliography driver.

EDIT 2: Comment by maetra:

I recognized that using this together with any of the author-year styles results in an extra space after the link if no pages are defined. Maybe you know a solution?

Solution:

In the version 1.6 of biblatex is a small bug in the file authoryear.bbx. The style redefine the macro issue+date. The redefinition of the macro depends on the option mergedate. If the option is set to true or compact the redefinition is as follows:

\renewbibmacro*{issue+date}{%
  \iffieldundef{issue}
    {}
    {\printtext[parens]{\printfield{issue}}}
  \newunit}%

Before the last \newunit work there is a none escaped space which results in the extra space. So you have to do this:

\renewbibmacro*{issue+date}{%
  \iffieldundef{issue}
    {}
    {\printtext[parens]{\printfield{issue}}}%
  \newunit}%

This fixes the problem.

EDIT 1: Changed Code.

\documentclass{article}
\usepackage[backend=biber,backref=true]{biblatex}
\addbibresource{biblatex-examples.bib}

\usepackage[colorlinks]{hyperref}

\ExecuteBibliographyOptions{doi=false}
\ExecuteBibliographyOptions{doi=false}
\DeclareFieldFormat{doilink}{%
\iffieldundef{doi}{#1}%
{\href{http://dx.doi.org/\thefield{doi}}{#1}}}

\DeclareBibliographyDriver{article}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{bytranslator+others}%
  \newunit\newblock
  \printfield{version}%
  \newunit\newblock
  \usebibmacro{in:}%
  \printtext[doilink]{%
  \usebibmacro{journal+issuetitle}%
  \newunit
  \usebibmacro{byeditor+others}%
  \newunit
  \usebibmacro{note+pages}%
  }%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{issn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}


\begin{document}
\cite{kastenholz}\qquad\cite{herrmann}\qquad\cite{sigfridsson}
\printbibliography
\end{document}

enter image description here

share|improve this answer
    
thanks Marco, this solves the problem of the period and the capital letter, unfortunately it adds two spaces after "In:" –  maetra Sep 7 '11 at 11:13
    
@maetra: The additional space based on the definition \DeclareFieldFormat{doilink}{. There I forgot to end the line with % –  Marco Daniel Sep 7 '11 at 11:39
    
this code is not working anymore, it seems as if you made too many changes –  maetra Sep 7 '11 at 11:59
    
@maetra: The code works well for me. –  Marco Daniel Sep 7 '11 at 12:01
    
@maetry: What's your problem. Has you recognised that I use backend=biber. I use biblatex v1.6. –  Marco Daniel Sep 7 '11 at 12:20
show 10 more comments

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.