# How to avoid “Infinite glue shrinkage found in a paragraph.” error with enumitem and nameref

There seems to be a problem when combining the enumitem and nameref package. With the code below I get the error:

! Infinite glue shrinkage found in a paragraph.

I already checked the package documentation but neither package mentions the other as problematic in combination.

Removing the enumitem package gets rid of the error, but I need that package elsewhere in the document. This also shows the result that I am after, i.e. a cross-reference with the item label "Label".

Code:

\documentclass{article}
\usepackage{enumitem}
\usepackage{nameref}

\begin{document}

\begin{description}
\item [Label\label{Ref}] Text
\end{description}

\begin{itemize}
\item \nameref{Ref}
\end{itemize}

\end{document}

• I'm not sure \item [Label\label{Ref}] does what you think it does. Changing \nameref to \ref (to make it compile) we find this in the aux: \newlabel{Ref}{{}{1}{\enit@align {\enit@format {Label\label {Ref}}}}{}{}} I'm not sure those commands are meant to be used outside \item[...] of a description env. – daleif Jan 29 at 9:16
• \item[Label]\label{Ref} – egreg Jan 29 at 9:31
• @egreg it still gives no output for \nameref, but I don't think it would ever had anyways – daleif Jan 29 at 9:44
• @daleif When I remove the enumitem package it does what I want it to do, i.e. show a cross-reference with "Label". Is that not what is to be expected? – Daniel Jan 29 at 10:06
• @daleif enumitem has no fault in this. It's rather gettitlestring. See github.com/ho-tex/gettitlestring/issues/1 – egreg Jan 29 at 10:38

The nameref package uses gettitlestring that has code to support enumitem, but it is incomplete: it only manages \enit@format, but not \enit@align.

\documentclass{article}
\usepackage{enumitem}
\usepackage{nameref}

\makeatletter
\GTS@TestLeft\enit@align\GTS@Cdr % package enumitem
}
\let\enit@align\@empty % package enumitem
}
\makeatother

\begin{document}

\begin{description}
\item [Label\label{Ref}] Text
\end{description}

\begin{itemize}
\item \nameref{Ref}
\end{itemize}

\end{document}


Without the fix, the .aux file contains

\newlabel{Ref}{{}{1}{\enit@align {\enit@format {Label\label {Ref}}}}{}{}}


With the fix,

\newlabel{Ref}{{}{1}{Label}{}{}}