8

See this basic MWE. Protrusion works beautifully.

\documentclass{article}
\usepackage[hidelinks]{hyperref}
\usepackage{microtype}
\begin{document}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
Ut purus elit, vestibulum ut, 
placerat ac, adipiscing vitae, felis. 
Curabitur dictum gravida mauris. Nam arcu libero, 
nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula 
augue eu neque. Pellentesque habitant morbi 
tristique senectus et netus et malesuada fames ac turpis egestas. 
Mauris ut leo. Cras viverra metus rhoncus sem. 
\end{document}

Now, I add some \href{}{} command to the protruded comma and period:

\documentclass{article}
\usepackage[hidelinks]{hyperref}
\usepackage{microtype}
\begin{document}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
Ut purus \href{http://tex.stackexchange.com}{elit,} vestibulum ut, 
placerat ac, adipiscing vitae, felis. 
Curabitur dictum gravida mauris. Nam arcu libero, 
nonummy eget, consectetuer id, vulputate a, \href{http://tex.stackexchange.com}{magna.} Donec vehicula 
augue eu neque. Pellentesque habitant morbi 
tristique senectus et netus et malesuada fames ac turpis egestas. 
Mauris ut leo. Cras viverra metus rhoncus sem. 
\end{document}

As you can see when you compile the code above, protrusion stops working with hyperlinked characters.

  • I discovered this issue is engine-specific. When I compile this with LaTeX or LuaLaTex, protrusion works. But when I compile this with XeLaTeX, protrusion doesn't work. Can I make it work with XeLaTeX?
  • Welcome to TeX.SE. You've posted a very concise MWE, by the way. It appears that you may have come across a bug in the microtype package -- specifically, its (inability) to notice that a hyperlink ends with a punctuation character if the document is compiled with XeTeX. Have you tried to contact the author/maintainer of the microtype package? His email address is stated on the front page of the package's user guide. – Mico Dec 18 '17 at 6:53
  • Nice question. To be sure whether it's an engine bug or microtype bug one would have to try to reproduce it in Plain TeX. – Henri Menke Dec 18 '17 at 9:59
4

Links in xelatex are done with a \special, a "whatsit" and they seem not to be transparent for protrusion. You can see a similar problem with \label. Imho it is a deficiency or a bug of the engine but the author of microtype could say something more definitive.

\documentclass{article}
\usepackage{microtype,tikz}
\begin{document}
\tikz[overlay]\draw[red](\textwidth-\parindent,0.5)--++(0,-20cm);%
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Ut purus {elit,} vestibulum ut,
placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris. Nam arcu libero,
nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula
augue eu neque. Pellentesque habitant morbi
tristique senectus et netus et malesuada fames ac turpis egestas.
Mauris ut leo. Cras viverra metus rhoncus sem.


Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Ut purus \special{}{elit,}\special{} vestibulum ut,
placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris. Nam arcu libero,
nonummy eget, consectetuer id, vulputate a, \special{}magna.\special{} Donec vehicula
augue eu neque. Pellentesque habitant morbi
tristique senectus et netus et malesuada fames ac turpis egestas.
Mauris ut leo. Cras viverra metus rhoncus sem.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Ut purus {elit,}\label{a} vestibulum ut,
placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris. Nam arcu libero,
nonummy eget, consectetuer id, vulputate a, magna.\label{b} Donec vehicula
augue eu neque. Pellentesque habitant morbi
tristique senectus et netus et malesuada fames ac turpis egestas.
Mauris ut leo. Cras viverra metus rhoncus sem.
\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.