The environment enumerate and its starred counterpart enumerate* behave slightly differently with \hypertarget. The latter, enumerate*, adds unwanted horizontal spacing.

The following descriptive MWE

\usepackage[shortlabels, inline]{enumitem}

Compare and contrast
    \item \hypertarget{spacing-nostar-correct-1}{} No extra space here.
    \item \hypertarget{spacing-nostar-correct-2}{} Nor any extra space here.

with the following:
    \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:
    \item \hypertarget{spacing-star-correct-1}{}No extra space here.
    \item \hypertarget{spacing-star-correct-2}{}Nor any extra space here.


yields the output Output of MWE

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?

  • 1
    targets are whatsits, they can change spacing, use them with the same care you would apply if you insert a normal letter or a color command there and do not leave spaces in the input that you don't want. Beside this hypertarget try to work both in horizontal mode and vertical mode, which means that they contain special code to test for the mode. If you want to use them in horizontal mode it is best to switch first with \leavevmode\hypertarget.... Aug 13 at 13:49


You must log in to answer this question.

Browse other questions tagged .