# Line break long glossaries entry when using hyperref and latex-dvips-ps2pdf

I am using the glossaries-extra package with hyperref. The problem I find occurs when I have a long (or unfortunately placed) long form of an acronym. In the case that I do not use breaklinks=true with hyperref I get a badbox. If I do use the breaklinks=true switch then the clickable links end up squished between lines.

\documentclass[]{memoir}

% V1 Causes a bad box
%\usepackage[]{hyperref}

% V2 Link box does not cover link
\usepackage[breaklinks=true]{hyperref}

\usepackage[acronyms,toc,symbols]{glossaries-extra}
\setabbreviationstyle[acronym]{long-short}
\newacronym{lng}{LONG}{This is a long form of an acronym which is very very very very very very very very long}

\begin{document}
Here is a long acronym: \gls{epc}
\end{document}


The output without use of breaklinks=true (V1) shows the badbox:

With the use of breaklinks=true (V2) the link area can be seen to be squashed between lines:

Ideally I would like the links to work nicely, though I would be quite happy with any tidy solution.

## Information

• I am using Ghostscript V9.23 old Ghostscript was implicated in this question.
• My toolchain is atex-dvips-ps2pdf. I would like to keep this as it helps with .eps graphics inclusion.
• dvips can't break links. You even get warning in the log: "You have enabled option breaklinks'. But driver hdvips.def' does not support this. Expect trouble with the link areas of broken links.". Switch to another toolchain (pdflatex or latex+ dvipdfmx) if you want such links. May 30, 2018 at 16:10
• Do you really need the first use to be hyperlinked to the glossary (since you don't have a separate description, what's gained by the link)? You can just disable it on first use with \glssetcategoryattribute{acronym}{nohyperfirst}{true}. Then only the shorter subsequent use will have hyperlinks. Jun 1, 2018 at 11:06

## 2 Answers

Here is a solution as suggested by @leandriis in the comments (many thanks).

Simply load the hypdvips package in the preamble after hyperref. Also after cleverref if you are using it.

Here is a fixed MWE:

\documentclass[]{memoir}

% Causes a bad box - now fixed!
\usepackage[]{hyperref}

\usepackage[acronyms,toc,symbols]{glossaries-extra}
\setabbreviationstyle[acronym]{long-short}
\newacronym{lng}{LONG}{This is a long form of an acronym which is very very very very very very very very long}

% If you are using cleverref, load this before hypdvips
%\usepackage{cleverref}

% Added package to solve the problem
\usepackage[]{hypdvips}

\begin{document}
Here is a long acronym: \gls{lng}
\end{document}


Note that the link boxes only appear correctly in a pdf viewer that supports at least PDF 1.6. (Credit to @Heiko Oberdiek for this)

Here is what the solution looks like in a pdf viewer that does not support PDF 1.6:

And here is the full solution, viewing the same output in Acrobat Reader:

This solution allows you to continue using the latex-dvips-ps2pdf toolchain.

Since you're using the long-short abbreviation style (rather than long-short-desc that has an accompanying description), there's no benefit in having a hyperlink on first use, since there's no extra information in the list of acronyms (apart from the location list). So an alternative approach is to disable the hyperlinks on first use for just the acronym category:

\documentclass[]{memoir}

\usepackage{hyperref}

\usepackage[acronyms,symbols]{glossaries-extra}

\makeglossaries

% no hyperlink on first use for entries with category=acronym
\glssetcategoryattribute{acronym}{nohyperfirst}{true}

\setabbreviationstyle[acronym]{long-short}
\newacronym{lng}{LONG}{This is a long form of an acronym which is very very very very very very very very long}

% for comparison:
\glsxtrnewsymbol[description={Archemedes' constant}]{pi}{\ensuremath{\pi}}

\newglossaryentry{sample}{name={sample},description={an example}}

\begin{document}
A \gls{sample} term for comparison.

Here is a long acronym: \gls{lng}.

Here's the next use: \gls{lng}.

And a symbol \gls{pi} for comparison.

\printglossaries
\end{document}


This doesn't affect the sample general term (which has category=general) or the pi symbol (which has category=symbol):

This setting doesn't affect \glsxtrfull or \glsxtrlong, but you can use the starred form \glsxtrfull*{lng} or \glsxtrlong*{lng} to suppress the hyperlink in this case.