XeTeXlinks after \paragraph{...} cause heading to be a link

Information and discussion about XeTeX, an alternative for pdfTeX based on e-Tex
Post Reply
doonyakka
Posts: 9
Joined: Fri May 28, 2010 2:50 pm

links after \paragraph{...} cause heading to be a link

Post by doonyakka »

Hi,

I've recently converted a long document from LaTeX to XeLaTeX and nearly everything's working, but I've found that if I have citation (or anything else that hyperref turns into a link) immediately after a \paragraph{...} heading, the heading itself will be part of the link. An example will illustrate this better than I can explain it, so here it is:

Code: Select all

\RequirePackage{filecontents}
\begin{filecontents}{test.bib}
@book{citation,
  author = {Smith, John},
  title = {{Yet Another Fake Citation}},
  year = {2011},
  publisher = {(nonexistent)}
  }
\end{filecontents}

\documentclass{article}

\usepackage[english]{babel}
\usepackage[xetex]{hyperref}
\usepackage{url}

\usepackage{xltxtra}
\setmainfont[Mapping=tex-text]{Linux Libertine O}%
\usepackage[round]{natbib}

\begin{document}

\label{thispage}

\paragraph{This is a link} \pageref{thispage}st page 
\paragraph{This is also a link} \citet{citation}.
\paragraph{This is not a link} because this is plain text.

\bibliographystyle{plainnat}
\bibliography{test}

\end{document}
This doesn't happen in LaTeX. Am I doing something wrong? Any idea what's causing it, and how to fix it?

Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

links after \paragraph{...} cause heading to be a link

Post by localghost »

A very interesting phenomenon which seems to be related to some hyperref internals. I suggest to post this on comp.text.tex (ctt) since there are the experts. Feel free to report the result after you got an answer there.


Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
doonyakka
Posts: 9
Joined: Fri May 28, 2010 2:50 pm

links after \paragraph{...} cause heading to be a link

Post by doonyakka »

Hi Thorsten,

I posted my question on comp.text.tex and the hyperref package Maintainer, Heiko Oberdiek, got back to me very quickly. As you suggest, it's due to a bug in hyperref. It'll be fixed in the next release but, in the meantime, Heiko suggests the following:
Workaround: Add \leavevmode (or \mbox{}) before
\pageref and \citet.

Fixed in hyperref 2011/04/17 v6.82g. Upload is on its way.
GL replied to Heiko with the following comment, which may be of help:
I would have proposed \ \unskip
because \null don't seem to have any effect. But \mbox{} is simpler !
Cheers,
Antonio
Post Reply