# Hyperlink occurs empty space also for Centered text

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}
onlyText for Testingphase onlyText for Testingphase onlyText for Testingphase
onlyText for Testingphase onlyText for Testingphase only}}
\end{center}

\end{document}


Output:

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}
\documentclass{article}

\usepackage{hyperref}

\begin{document}

\begin{center}
onlyText for Testingphase onlyText for Testingphase onlyText for Testingphase
onlyText for Testingphase onlyText for Testingphase only}}
\end{center}

\end{document}


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

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}
onlyText for Testingphase onlyText for Testingphase onlyText for Testingphase
onlyText for Testingphase onlyText for Testingphase only}

\bigskip