Skip to content

Theorem patch with cleveref and amsthm loaded #413

@sim642

Description

@sim642

The theorem patch does the following:

hyperref/hyperref.dtx

Lines 11129 to 11135 in d2eb2fa

\@ifpackageloaded{cleveref}
{\AddToHook{cmd/@thm/before}{\ifhmode\unskip\fi}}
{%
\ifpatchable\@thm{\refstepcounter}
{\patchcmd\@thm{\refstepcounter}{\Hy@theorem@refstepcounter}{}{}}
{}%
}}}{}

If cleveref is loaded, it hooks some spacing stuff in there. I guess it's because cleveref with amsthm loaded redefines things with

  \let\cref@thmnoarg\@thm%
  \def\@thm{\@ifnextchar[{\cref@thmoptarg}{\cref@thmnoarg}}%]

Or maybe there's another reason I don't understand.

Anyway, what I'm confused about is the \refstepcounter patch in \@thm. If cleveref is loaded, then this patch isn't being done at all, but why not?
Patching \@thm no longer works, but patching \cref@thmnoarg seems like it does.

For completeness, \cref@thmoptarg should probably also be patched then, but that would probably also require a variant of \Hy@theorem@refstepcounter with an optional argument, like \cref@thmoptarg wants to use it.

I guess this might be related to #336 and latex3/latex2e#1779. And perhaps amsthm should just be improved like latex3/latex2e#1301, instead of piling more patches on top of each other for this package combination.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions