Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nameref and enumitem #19

Open
u-fischer opened this issue Jul 17, 2019 · 1 comment
Open

nameref and enumitem #19

u-fischer opened this issue Jul 17, 2019 · 1 comment

Comments

@u-fischer
Copy link

on tex.sx a question about the incompability of enumitem with nameref was asked.

I think one could resolve the problem if enumitem had a hook in the right places that nameref could detect and use instead of redefining \descriptionlabel.

https://tex.stackexchange.com/a/500401/2388

@jbezos
Copy link
Owner

jbezos commented Jul 18, 2019

I'll have a look at it. Here is the proposed code:

\documentclass{article}

\usepackage{enumitem}
\makeatletter
\newcommand\enit@descriptionlabel@hook[1]{}
\def\enit@description@i#1#2#3#4{%
  \ifnum#1>#3\relax
    \enit@toodeep
  \else
    \enit@list{}%
      {\let\enit@type\tw@
       \advance#1\@ne
       \labelwidth\z@
       \enit@align@left
       \let\makelabel\descriptionlabel
       \enit@style@standard
       \enit@preset{#2}{#1}{#4}%
       \enit@calcleft
       \let\enit@svlabel\makelabel
       \def\makelabel##1{%
         \NR@gettitle{##1}%
         \labelsep\z@
         \ifenit@boxdesc
           \enit@svlabel{\enit@align{\enit@format{\enit@descriptionlabel@hook{##1}}}}%
         \else
           \nobreak
           \enit@svlabel{\enit@format{\enit@descriptionlabel@hook{##1}}}%
           \aftergroup\enit@postlabel
         \fi}%
       \enit@before
       \enit@negwidth}%
     \enit@keyfirst
  \fi}

\usepackage{hyperref} 
\AtBeginDocument{\let\descriptionlabel\NRorg@descriptionlabel}
\renewcommand\enit@descriptionlabel@hook[1]{\NR@gettitle{#1}#1}
\begin{document}


\begin{description}
  \item [{Test}\label{Test}] Some text
\end{description}

\nameref{Test}

\end{document}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants