2

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
  • 1
    @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
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}{}{}}
| improve this answer | |

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.