Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Biblatex, hyperref and punctuation issue

23 views
Skip to first unread message
Message has been deleted
Message has been deleted

meho_r

unread,
Dec 13, 2010, 7:04:43 AM12/13/10
to
I posted this question earlier here:
http://tex.stackexchange.com/questions/6946/biblatex-hyperref-and-punctuation-issue

I'll keep them both in sync. So, here's the question:

I've noticed that, when using hyperref, there is an issue in form of
an ugly space between the citation and the punctuation (be it comma
or
period). Please, take a look at the following example code:

\begin{filecontents}{mybib.bib}
@book{JSmith,
author = {Smith, John},
title = {A book of}
}

\end{filecontents}

\documentclass{article}

\usepackage[style=authortitle]{biblatex}
\bibliography{mybib.bib}

\usepackage[colorlinks]{hyperref}

\begin{document}
Test~\cite*{JSmith}. Test~\footcite{JSmith}

Test~\emph{A book of}. Test\footnote{Smith, \emph{A book of}.}
\end{document}

Any ideas?

Heiko Oberdiek

unread,
Dec 15, 2010, 7:57:22 AM12/15/10
to
meho_r <meho...@gmail.com> wrote:

> Hi. I've noticed that, when using hyperref, there is an issue in form


> of an ugly space between the citation and the punctuation (be it comma
> or period). Please, take a look at the following example code:
>

> %%%%%%%%%%%%%%%%


> \begin{filecontents}{mybib.bib}
> @book{JSmith,
> author = {Smith, John},
> title = {A book of}
> }
> \end{filecontents}
>
> \documentclass{article}
>
> \usepackage[style=authortitle]{biblatex}
> \bibliography{mybib.bib}
>
> \usepackage[colorlinks]{hyperref}
>
> \begin{document}
> Test~\cite*{JSmith}. Test~\footcite{JSmith}
>
> Test~\emph{A book of}. Test\footnote{Smith, \emph{A book of}.}
> \end{document}

> %%%%%%%%%%%%%%%
>
> Any ideas?

\cite* uses \emph and \emph suppresses the italic correction at the
right end if a comma or period follows (\nocorrlist). However adding a
link implies that whatits are added in between (in case of hpdftex.def
there are two whatits, the end of the link and restoring the color.
Therefore the period is hidden from \emph.

Example without biblatex:

\documentclass[12pt]{article}
\showboxdepth=\maxdimen
\showboxbreadth=\maxdimen
\usepackage[colorlinks]{hyperref}

\begin{document}
\section{Foo}\label{sec:foo}
\huge
\noindent
Test~\emph{Smith of}.\\
Test~\hyperref[sec:foo]{\emph{Smith of}}.

\tracingonline=1
\showlists
\end{document}

--
Heiko Oberdiek

meho_r

unread,
Dec 15, 2010, 9:29:32 AM12/15/10
to
On Dec 15, 1:57 pm, Heiko Oberdiek <heiko.oberd...@googlemail.com>
wrote:

Thanks for the answer. So, what can we (users) do about it?

Heiko Oberdiek

unread,
Dec 15, 2010, 11:21:21 AM12/15/10
to
meho_r <meho...@gmail.com> wrote:

> Thanks for the answer. So, what can we (users) do about it?

Except manual corrections?

I don't have a good idea for fixing it in a general way
except doing it using LuaTeX.

--
Heiko Oberdiek

Ulrike Fischer

unread,
Dec 15, 2010, 11:34:47 AM12/15/10
to
Am Wed, 15 Dec 2010 06:29:32 -0800 (PST) schrieb meho_r:

>>> Hi. I've noticed that, when using hyperref, there is an issue in form
>>> of an ugly space between the citation and the punctuation (be it comma
>>> or period). Please, take a look at the following example code:

>> \cite* uses \emph and \emph suppresses the italic correction at the


>> right end if a comma or period follows (\nocorrlist). However adding a
>> link implies that whatits are added in between (in case of hpdftex.def
>> there are two whatits, the end of the link and restoring the color.
>> Therefore the period is hidden from \emph.

> Thanks for the answer. So, what can we (users) do about it?

You can locally reset the definition of \citetitle (if you do it
globally it will perhaps remove the italic correction also in places
where you want it):

{\DeclareFieldFormat{citetitle}{\mkbibemph{#1\nocorr}}\cite*{JSmith}.}

Apart from this I would suggest that you notify the biblatex author.
Perhaps he has an idea.


--
Ulrike Fischer

meho_r

unread,
Dec 15, 2010, 3:32:05 PM12/15/10
to

Thank you both for your suggestions. I'll also send an email to
Philipp to see what he'd advise.

Regards,

M.

Philipp Lehman

unread,
Dec 16, 2010, 9:40:34 AM12/16/10
to
meho_r wrote:

> So, what can we (users) do about it?

Not much, I'm afraid, short of manual workarounds.

\emph and friends use a rather simple look-ahead routine to decide
whether or not italic correction is required. A simple \relax will
confuse it. Compare this:

\emph{of}.
\emph{of}\relax.

Once the italic correction has been added, all you can do is remove it
manually. It's a \kern, hence you may use \unkern:

\emph{of}\relax\unkern.

In fact, biblatex does precisely that automatically. If you comment
out hyperref, your example will be fine.

Unfortunately, this won't work if the text in italics is a link while
the punctuation is not part of the link:

\href{http://www.foobar.com}{\emph{of}}.
\href{http://www.foobar.com}{\emph{of}}\unkern.

The \unkern kicks in too late. It would need to move inside the link
group to do its job:

\href{http://www.foobar.com}{\emph{of}\unkern}.

Trouble is: you need to remove the italic correction inside the link
group but you don't know if you need to remove it until after the
link.

I don't see any way to deal with that automatically. These are
potentially deeply nested structures. There could be dozens of tokens
and multiple groups between the end of the link and the punctuation.

You can either disable links (hyperref=false) or set up a special
\cite command with a decicated format definition suppressing the
italic correction. So, along the lines of what Ulrike has suggested,
here's my take:

\DeclareFieldFormat{nocorremph}{\mkbibemph{#1\nocorr}}
\newrobustcmd{\nccite}{%
\AtNextCite{\DeclareFieldAlias{citetitle}{nocorremph}}
\cite}

Now compare:

\cite*{JSmith}.
\nccite*{JSmith}.

Not nice, but it works.

--
Sender address blackholed, do not reply directly.
You can still reach me by email at: lehman gmx net.

meho_r

unread,
Dec 16, 2010, 11:56:17 AM12/16/10
to
On Dec 16, 3:40 pm, Philipp Lehman <devnull.1.leh...@spamgourmet.com>
wrote:

OK, that solution would do nicely. Thanks a lot for the answer.

Regards,

Meho R.

0 new messages