The environment enumerate
and its starred counterpart enumerate*
behave slightly differently with \hypertarget
. The latter, enumerate*
, adds unwanted horizontal spacing.
The following descriptive MWE
\documentclass[12pt]{book}
\usepackage[shortlabels, inline]{enumitem}
\usepackage[hypertexnames=false]{hyperref}
\begin{document}
Compare and contrast
\begin{enumerate}
\item \hypertarget{spacing-nostar-correct-1}{} No extra space here.
\item \hypertarget{spacing-nostar-correct-2}{} Nor any extra space here.
\end{enumerate}
with the following:
\begin{enumerate*}
\item \hypertarget{spacing-star-incorrect-1}{} An extra space here. %% <<- Notice the space after hypertarget in code.
\item \hypertarget{spacing-star-incorrect-2}{} And an extra space here.
\end{enumerate*} %% <<- Notice the space after hypertarget in code.
and with:
\begin{enumerate*}
\item \hypertarget{spacing-star-correct-1}{}No extra space here.
\item \hypertarget{spacing-star-correct-2}{}Nor any extra space here.
\end{enumerate*}
\end{document}
Intended spacing is marked with green rectangles, and unintended with red diamonds. There is some extra spacing added when a space succeeds \hypertarget
in enumerate*
but not in enumerate
.
What would be a better solution than removing the spacing in code by hand?
\leavevmode\hypertarget...
.