2

Using LuaLaTeX, I am getting hyperlink anchors in unwanted places, shown in the MWE (PDFLaTeX, XeLaTeX produces prompt output). I only want the actual text to function as an anchor, not the surrounding whitespace.

MWE:

\documentclass{article}

\usepackage{hyperref}

\begin{document}

\begin{center}
{\href{www.google.com}{Text for Testingphase
onlyText for Testingphase onlyText for Testingphase onlyText for Testingphase
onlyText for Testingphase onlyText for Testingphase only}}
\end{center}

\end{document}

Output: MWE-Output

0

2 Answers 2

1

This is highly experimental and might change, but you can try a package I'm working on for this:

Download this file and save it as lua-links.sty next to your document. Then load the lua-links package with the discard option:

\RequirePackage{pdfmanagement-testphase}
\DocumentMetadata{}
\documentclass{article}

\usepackage{hyperref}
\usepackage[discard]{lua-links}

\begin{document}

\begin{center}
{\href{www.google.com}{Text for Testingphase
onlyText for Testingphase onlyText for Testingphase onlyText for Testingphase
onlyText for Testingphase onlyText for Testingphase only}}
\end{center}

\end{document}

enter image description here

1
  • It works. Appreciated for your efforts. May 19 at 11:30
5

If you want to avoid that you must break the line manually and use a \href on every one. Personally I would avoid such a large link area completely, it is imho quite a nuisance if too large parts of a document are active.

\documentclass{article}

\usepackage{hyperref}

\begin{document}

\begin{center}
\href{www.google.com}{Text for Testingphase
onlyText for Testingphase onlyText for Testingphase onlyText for Testingphase
onlyText for Testingphase onlyText for Testingphase only}

\bigskip

\href{www.google.com}{Text for Testingphase
onlyText for Testingphase onlyText for Testingphase}\\
\href{www.google.com}{onlyText for Testingphase
onlyText for Testingphase onlyText for}\\
\href{www.google.com}{Testingphase only}
\end{center}

\end{document}

enter image description here

2
  • Unfortunately, we required hyperlink for larger text part as per the MWE provided. Though this is quite a nuisance request, is it possible to get a solution like the way we are getting with PDFLaTeX, XeLaTeX. May 17 at 17:48
  • 1
    @KumareshPS you could try github.com/zauguin/lua-links May 18 at 19:00

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.