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?
> 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
Thanks for the answer. So, what can we (users) do about it?
> 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
>>> 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
Thank you both for your suggestions. I'll also send an email to
Philipp to see what he'd advise.
Regards,
M.
> 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.
OK, that solution would do nicely. Thanks a lot for the answer.
Regards,
Meho R.