I already asked a related question, How can I label / reference description items that contain macros by name?
Now I am having difficulty compiling description lists using hyperref
's hyperlinks.
Problem
I'd like to make description list items (let's call each item a key-value pair) that contains hyperlinks in its keys.
Code
The description list has already been redefined once to allow label references to macros (namely the macros provided by menukeys
).
\documentclass{article}
\usepackage{fontspec} % for xelatex
\usepackage{hyperref}
\usepackage{enumitem}
\setlist[description]{style=nextline,labelwidth=0pt,leftmargin=30pt,itemindent=\dimexpr-20pt-\labelsep\relax} % Global Setup Description List
\makeatletter % Redefinition of Description List Items source: https://tex.stackexchange.com/a/1248/13552
\let\orgdescriptionlabel\descriptionlabel
\renewcommand*{\descriptionlabel}[1]{%
\let\orglabel\label
\let\label\@gobble
\phantomsection
\protected@edef\@currentlabel{#1}%
%\edef\@currentlabelname{#1}%
\let\label\orglabel
\orgdescriptionlabel{#1}%
}
\makeatother
\begin{document}
\section{User Interface}
The following is a list of important user interface components:
\begin{description}
\item [Main Window] The main window. % <-- Not so cool.
\item [Side Bar] for navigation. % <-- Not so cool.
\item [Document Tree] A document tree. % <-- Not so cool.
%\item [\hyperlink{gui:mainwindow}{Main Window}] The main window. % <-- way cooler
%\item [\hyperlink{gui:sidebar}{Side Bar}] for navigation. % <-- way cooler
%\item [\hyperlink{gui:documenttree}{Document Tree}] A document tree. % <-- way cooler
\end{description}
\hypertarget{gui:mainwindow}{\subsection{Main Window}}
Some nice long description.
\hypertarget{gui:sidebar}{\subsection{Side Bar}}
Some nice long description.
\hypertarget{gui:documenttree}{\subsection{Document Tree}}
Some nice long description.
\end{document}
\protect\hyperlink
, but this has to be done each time :-(, unlessrobustified
or a (weird) redefinition of\item
– user31729 Mar 3 '16 at 13:59\hyperlink
s in curly braces and it worked... (XeTeX 2.6) – Tom Jun 29 '18 at 13:56