1

Is there a way to have hyperref shift the boxes when a kern is applied to the text to be linked to?

enter image description here

There does seem to be an attempt to keep up with the kern, but seems to be quite a bit off?

Code:

\documentclass{article}
\usepackage[colorlinks=false]{hyperref} 

\begin{document}

\par\hspace*{2.0cm}\href{https://tex.stackexchange.com}{TeX.SE}
\par\hspace*{2.0cm}\href{https://tex.stackexchange.com}{$\!$TeX.SE}
\par\hspace*{2.0cm}\href{https://tex.stackexchange.com}{$\!\!$TeX.SE}
\par\hspace*{2.0cm}\href{https://tex.stackexchange.com}{$\!\!$TeX.SE}
\end{document}
10
  • The link box follows the bounding box. You can easily see it if you add a \fbox around the the \href. How should hyperref know that you move the text outside the box with a negative space? Apr 17, 2017 at 9:14
  • don't you want the negative space before the \href not inside it? Apr 17, 2017 at 9:21
  • @UlrikeFischer: Good point. But, wondering why there is any shifting of the box then? Apr 17, 2017 at 10:07
  • @DavidCarlisle: Well, that is rather complicated in my actual use case as the text (with the kern to be applied) comes from quite a few macro levels above so will need a lot of changes to separate the negative spacing and the text to be applied. Was hoping that there was a way to move the hyperref box itself. Apr 17, 2017 at 10:09
  • You mean on the right? You are making the bounding box smaller with the negative space. This is not specific to links. Try out as I suggested with \fbox. Apr 17, 2017 at 10:10

1 Answer 1

3

Compare:

\documentclass{article}
\usepackage[colorlinks=false]{hyperref} 

\begin{document}

\par\hspace*{2.0cm}\href{https://tex.stackexchange.com}{TeX.SE}
\par\hspace*{2.0cm}\href{https://tex.stackexchange.com}{$\!$TeX.SE}
\par\hspace*{2.0cm}\href{https://tex.stackexchange.com}{$\!\!$TeX.SE}
\par\hspace*{2.0cm}\href{https://tex.stackexchange.com}{$\!\!$TeX.SE}



\par\hspace*{2.0cm}\frame{TeX.SE}
\par\hspace*{2.0cm}\frame{$\!$TeX.SE}
\par\hspace*{2.0cm}\frame{$\!\!$TeX.SE}
\par\hspace*{2.0cm}\frame{$\!\!$TeX.SE}



\end{document}

enter image description here

hyperef doesn't see the negative space at all, just as for \frame (a tighter version of \fbox) if you add negative space the effective width of the text is reduced.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .