3

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}
9
  • 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
    Commented Jan 29, 2020 at 9:16
  • \item[Label]\label{Ref}
    – egreg
    Commented Jan 29, 2020 at 9:31
  • @egreg it still gives no output for \nameref, but I don't think it would ever had anyways
    – daleif
    Commented Jan 29, 2020 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
    Commented Jan 29, 2020 at 10:06
  • 1
    @daleif enumitem has no fault in this. It's rather gettitlestring. See github.com/ho-tex/gettitlestring/issues/1
    – egreg
    Commented Jan 29, 2020 at 10:38

1 Answer 1

2

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
\g@addto@macro\GTS@PredefinedLeftCmds{%
  \GTS@TestLeft\enit@align\GTS@Cdr % package enumitem
}
\g@addto@macro\GTS@DisablePredefinedCmds{%
  \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}

enter image description here

Without the fix, the .aux file contains

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

With the fix,

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .