1

This answer demonstrates how to use the aliascnt method to create an ineq environment which shares a counter with the equation environment, but which cleveref can nevertheless recognize as a different environment than equation.

The code which the answer uses to define the ineq environment is copied from the code used in latex.ltx to define the equation environment. Consequently, the answer is specific to situations in which it is desirable to define equation-like environments.

However, how can the aliascnt method be used when the new environment to be defined is similar to theorem rather than to equation, as described in this question?

3
  • Please provide a few more details about "the new environment to be defined similar to theorem". E.g., does this new environment have a name? And, would this "new environment" share a counter with the theorem environment? For that matter, how is the theorem environment defined in the first place? E.g., with the help of the amsthm or ntheorem package? (The more details you can provide, the more specific and more pertinent answers are likely to be too.)
    – Mico
    Nov 30, 2022 at 20:49
  • 1
    @Mico The MWE is the one described in this question, to which I also refer in my post above. If you want, I can copy and paste it into my current post. The MWE does not use ntheorem.
    – Evan Aad
    Nov 30, 2022 at 21:43
  • Please see the answer I just posted.
    – Mico
    Nov 30, 2022 at 23:12

1 Answer 1

2

The thing that's wrong about the MWE in the posting referenced by the OP is that the cleveref package is loaded too late, i.e., only after the \newtheorem directives are executed. If the \usepackage{cleveref} is placed after \usepackage{amsthm} and before \newtheorem, the \cref command produces the expected, i.e., correct, output.

FWIW, the need to load the cleveref package before the \newtheorem commands are executed if the amsthm (or ntheorem) package is loaded is mentioned several times in the user guide of the cleveref package. E.g., in section 14.1, "Non-bugs", the second bullet point states [highlighting added]:

enter image description here

Finally, I see no need to incur the hassles of the aliascnt method -- at least not for the use case at hand.

enter image description here

\documentclass{article}
\usepackage{amsthm,cleveref}
\newtheorem{definition}{Definition}
\newtheorem{theorem}[definition]{Theorem}

\begin{document}
\begin{definition}\label{d}
This is a definition.
\end{definition}

\begin{theorem}\label{t}
This is a theorem.
\end{theorem}

Here is a cross-reference to~\cref{t}.
\end{document}
4
  • 1
    There should be a reason why I recommend to load the needed packages and then do settings. ;-)
    – egreg
    Dec 1, 2022 at 0:08
  • Thank you. You wrote: "the need to load the cleveref package before the \newtheorem commands are executed is discussed in section 8.1.3 the user guide of the cleveref package." I don't see any hint of this in section 8.1.3 of the user guide. At the same time, section 13 starts with the admonition: "the \usepackage{cleveref} line should usually be the last \usepackage command in your document’s preamble."
    – Evan Aad
    Dec 1, 2022 at 0:09
  • I don't know whether to accept your answer. On the one hand, you didn't answer the question I asked, namely about the aliascnt method. On the other hand, you answered the question I was actually interested in, and the impetus for the current question.
    – Evan Aad
    Dec 1, 2022 at 0:12
  • 1
    @EvanAad - I've edited the answer to provide a clearer reference in the user guide to the need to load cleveref *before` running \newtheorem.
    – Mico
    Dec 1, 2022 at 1:29

You must log in to answer this question.

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