1

I'm writing a document with lots of \hypertarget and \hyperlink in them using pdflatex.

I'm trying to get the text of

\hyperlink{label}{very long text that should line break}

to line break. Similarly with

\hyperref[label]{very long text that should line break}

I'm including hyperref with

\usepackage[linktocpage,
            ocgcolorlinks,
            allcolors=blue,
            breaklinks]{hyperref}

unfortunately to no avail. How can I get the link text to line break?

3

hyperref's ocgcolorlinks option prevents line breaking inside the link text.

Use package ocgx2 instead. It allows longer link text to wrap around line and page breaks:

\usepackage[linktocpage,allcolors=blue]{hyperref}
\usepackage[ocgcolorlinks]{ocgx2}

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.