1

Please consider this MWE:

\documentclass{article}
\usepackage{lineno}
\usepackage{hyperref}
% \linenumbers
\begin{document}
\url{https://www.this-is-a-very-long-url.com/this-is-a-very-long-url/this-is-a-very-long-url/this-is-a-very-long-url.html}
\end{document}

Using pdflatex, this results in: without line numbers

If we uncomment the \linenumbers line, an additional (small) colored box is drawn before the URL: with line numbers

Using xelatex, the box is drawn around the line number: using xelatex

What's the reason for this extra box? Is there a way to avoid it?

rmolina
  • 183

1 Answers1

2

the line number is in a box which is placed while the link is build, so it is linked too.

With a current texsystem (texlive 2021) you can avoid it. But this requires to patch an internal command of lineno as the deactivation code must be at the correct box level:

\documentclass{article}
\usepackage{lineno}

\usepackage{hyperref}

\usepackage{iftex,etoolbox} \ifxetex \newcommand\runninglinkoff{\special{pdf: nolink}} \newcommand\runninglinkon {\special{pdf: link}} \fi \ifpdftex \newcommand\runninglinkoff{\pdfrunninglinkoff} \newcommand\runninglinkon {\pdfrunninglinkon} \fi \ifluatex \protected\def\runninglinkoff{\pdfextension linkstate 1 } \protected\def\runninglinkon {\pdfextension linkstate 0 } \fi

\makeatletter \patchcmd@LN@depthbox{\box@tempboxa}{\runninglinkoff\box@tempboxa \runninglinkon}{}{\fail} \makeatother
\begin{document} \linenumbers \url{https://www.this-is-a-very-long-url.com/this-is-a-very-long-url/this-is-a-very-long-url/this-is-a-very-long-url.html} \end{document}

enter image description here

Ulrike Fischer
  • 327,261