The following source causes the "EXERCSISES" head in the theorem-like environment to be overwritten with the 1st item of the enumerated list inside:



postheadspace=0 pt ]{exercs}


    before=\leavevmode \vspace{-\dimexpr\baselineskip+\topsep\relax}





\item Do this one first.
\item Solve this next.





Commenting out the \usepackage{showkeys} or omitting the \label prevents the overwriting:


Is there some way to prevent the overwriting even with showkeys loaded and with the \label still included?

One way to prevent the overwriting when showkeys is not loaded is simply to remove the newline between \begin{problems} and the \label command:

\label{my problems}

However, even with that change, once showkeys is loaded the overwriting persists. Hence a more robust workaround would be desirable.

Note: The seemingly convoluted definition of the problemsenum environment is needed in order to be able to create cross-references to individual items in the problemsenum environment, with \cref, even though the theorem-like environment is unnumbered. (See How use cleveref to get theorem-like name and list item number? and How change vertical space after head in theorem-like environment .)

  • What are you trying to \label? There isn't anything there to refer to, is there?
    – cfr
    Sep 22, 2016 at 22:21
  • The adjustment done by showkeys operates in horizontal mode, I think. However, you have put TeX in vertical mode, also I think. Hence, no adjustment is done.
    – cfr
    Sep 22, 2016 at 22:41
  • You can put \hskip 0pt after \label. But you would be better advised to heed the recommendations provided in response to your earlier questions, I think.
    – cfr
    Sep 22, 2016 at 22:43
  • Do \usepackage[left]{showlabels} instead of \usepackage{showkeys}. The showlabels package is usually more robust than showkeys. David will appreciate.
    – egreg
    Sep 22, 2016 at 22:52
  • \leavevmode \vspace is a very weird construct, it forces the space into a vadjust node so that it is inserted after the paragraph has been broken into lines, after the first line of the paragraph. Sep 23, 2016 at 0:15

1 Answer 1


Packages like showkeys work at a quite deep level and make some assumptions about how certain things such as theorem labels are produced. In this case, your abuse of headpunct for inserting a \vspace confuses showkeys.

It turns out that the competitor in the field works for this special case:


This package is even more customizable than showkeys, so my advice is to switch. However, there's no guarantee that other complicated things like those you do here will work. In any case, both showkeys and showlabels are only used during the writing of the document, where some poor typesetting can be ignored.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .