Is there a way to make cleveref distinguish two environments with the same counter?












3















I believe that usually you explicitly tell cleveref what to call your label using crefname{type}{singular}{plural}, this doen't work however as here "type" has to be the name of the counter (I believe). I've also tried using label[type]{label} to no avail.
Is there any way to accomplish two environments sharing a counter, but have cleveref be able to distinguish between them? (Or is there maybe some way to use two counters, but for them always to be equal/dependent as to accomplish the same effect?)



Below is an example:



documentclass{article}
usepackage[colorlinks, linkcolor=blue]{hyperref}
usepackage[noabbrev, capitalise]{cleveref}
usepackage{tikz}

%new theorem environment
newcounter{theo}[section]setcounter{theo}{0}
renewcommand{thetheo}{arabic{section}.arabic{theo}}
newenvironment{theo}{%
refstepcounter{theo}%
tikz[baseline=(current bounding box.east),outer sep=0pt]
node[anchor=east,rectangle,fill=green!20]
{strut textbf{Theorem~thetheo.}};
newline
}

crefname{theo}{Theorem}{Theorems}

%new lemma environment
newenvironment{lem}{%
refstepcounter{theo}
tikz[baseline=(current bounding box.east),outer sep=0pt]
node[anchor=east,rectangle,fill=blue!20]
{strut textbf{Lemma~thetheo.}};
newline
}

begin{document}
begin{theo}label{thrm}
Just some text.
end{theo}

begin{lem}label{lm1}
Just some more text.
end{lem}

begin{lem}label[Lemma]{lm2}
Just some more text.
end{lem}

noindent
cref{thrm}\ %give Theorem 0.1
cref{lm1}\ %give Lemma 0.2
cref{lm2}\ %give Lemma 0.3
end{document}


At the bottom of the example I use cref three times. In a comment I display the desired output.
Here I used crefname{theo}{Theorem}{Theorems} to give the "theo"-environment the correct name, as you can see then the "lem"-environment gets the same name, when referred to. The second time I use the "lem"-environment, I label it using label[Lemma]{lm2}, which turns out not to have the desired effect.



(Note: The code that uses tikz is not relevant, I added it as a small justification for not using the newtheorem command instead.)










share|improve this question







New contributor




lamcar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • You could add a boolean to the environment, which would be set to true for only one of the environments and use a test in the command crefname{...}{...} to determine what to print.

    – Bernard
    6 hours ago








  • 1





    never end a paragraph with newline

    – David Carlisle
    6 hours ago
















3















I believe that usually you explicitly tell cleveref what to call your label using crefname{type}{singular}{plural}, this doen't work however as here "type" has to be the name of the counter (I believe). I've also tried using label[type]{label} to no avail.
Is there any way to accomplish two environments sharing a counter, but have cleveref be able to distinguish between them? (Or is there maybe some way to use two counters, but for them always to be equal/dependent as to accomplish the same effect?)



Below is an example:



documentclass{article}
usepackage[colorlinks, linkcolor=blue]{hyperref}
usepackage[noabbrev, capitalise]{cleveref}
usepackage{tikz}

%new theorem environment
newcounter{theo}[section]setcounter{theo}{0}
renewcommand{thetheo}{arabic{section}.arabic{theo}}
newenvironment{theo}{%
refstepcounter{theo}%
tikz[baseline=(current bounding box.east),outer sep=0pt]
node[anchor=east,rectangle,fill=green!20]
{strut textbf{Theorem~thetheo.}};
newline
}

crefname{theo}{Theorem}{Theorems}

%new lemma environment
newenvironment{lem}{%
refstepcounter{theo}
tikz[baseline=(current bounding box.east),outer sep=0pt]
node[anchor=east,rectangle,fill=blue!20]
{strut textbf{Lemma~thetheo.}};
newline
}

begin{document}
begin{theo}label{thrm}
Just some text.
end{theo}

begin{lem}label{lm1}
Just some more text.
end{lem}

begin{lem}label[Lemma]{lm2}
Just some more text.
end{lem}

noindent
cref{thrm}\ %give Theorem 0.1
cref{lm1}\ %give Lemma 0.2
cref{lm2}\ %give Lemma 0.3
end{document}


At the bottom of the example I use cref three times. In a comment I display the desired output.
Here I used crefname{theo}{Theorem}{Theorems} to give the "theo"-environment the correct name, as you can see then the "lem"-environment gets the same name, when referred to. The second time I use the "lem"-environment, I label it using label[Lemma]{lm2}, which turns out not to have the desired effect.



(Note: The code that uses tikz is not relevant, I added it as a small justification for not using the newtheorem command instead.)










share|improve this question







New contributor




lamcar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • You could add a boolean to the environment, which would be set to true for only one of the environments and use a test in the command crefname{...}{...} to determine what to print.

    – Bernard
    6 hours ago








  • 1





    never end a paragraph with newline

    – David Carlisle
    6 hours ago














3












3








3








I believe that usually you explicitly tell cleveref what to call your label using crefname{type}{singular}{plural}, this doen't work however as here "type" has to be the name of the counter (I believe). I've also tried using label[type]{label} to no avail.
Is there any way to accomplish two environments sharing a counter, but have cleveref be able to distinguish between them? (Or is there maybe some way to use two counters, but for them always to be equal/dependent as to accomplish the same effect?)



Below is an example:



documentclass{article}
usepackage[colorlinks, linkcolor=blue]{hyperref}
usepackage[noabbrev, capitalise]{cleveref}
usepackage{tikz}

%new theorem environment
newcounter{theo}[section]setcounter{theo}{0}
renewcommand{thetheo}{arabic{section}.arabic{theo}}
newenvironment{theo}{%
refstepcounter{theo}%
tikz[baseline=(current bounding box.east),outer sep=0pt]
node[anchor=east,rectangle,fill=green!20]
{strut textbf{Theorem~thetheo.}};
newline
}

crefname{theo}{Theorem}{Theorems}

%new lemma environment
newenvironment{lem}{%
refstepcounter{theo}
tikz[baseline=(current bounding box.east),outer sep=0pt]
node[anchor=east,rectangle,fill=blue!20]
{strut textbf{Lemma~thetheo.}};
newline
}

begin{document}
begin{theo}label{thrm}
Just some text.
end{theo}

begin{lem}label{lm1}
Just some more text.
end{lem}

begin{lem}label[Lemma]{lm2}
Just some more text.
end{lem}

noindent
cref{thrm}\ %give Theorem 0.1
cref{lm1}\ %give Lemma 0.2
cref{lm2}\ %give Lemma 0.3
end{document}


At the bottom of the example I use cref three times. In a comment I display the desired output.
Here I used crefname{theo}{Theorem}{Theorems} to give the "theo"-environment the correct name, as you can see then the "lem"-environment gets the same name, when referred to. The second time I use the "lem"-environment, I label it using label[Lemma]{lm2}, which turns out not to have the desired effect.



(Note: The code that uses tikz is not relevant, I added it as a small justification for not using the newtheorem command instead.)










share|improve this question







New contributor




lamcar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I believe that usually you explicitly tell cleveref what to call your label using crefname{type}{singular}{plural}, this doen't work however as here "type" has to be the name of the counter (I believe). I've also tried using label[type]{label} to no avail.
Is there any way to accomplish two environments sharing a counter, but have cleveref be able to distinguish between them? (Or is there maybe some way to use two counters, but for them always to be equal/dependent as to accomplish the same effect?)



Below is an example:



documentclass{article}
usepackage[colorlinks, linkcolor=blue]{hyperref}
usepackage[noabbrev, capitalise]{cleveref}
usepackage{tikz}

%new theorem environment
newcounter{theo}[section]setcounter{theo}{0}
renewcommand{thetheo}{arabic{section}.arabic{theo}}
newenvironment{theo}{%
refstepcounter{theo}%
tikz[baseline=(current bounding box.east),outer sep=0pt]
node[anchor=east,rectangle,fill=green!20]
{strut textbf{Theorem~thetheo.}};
newline
}

crefname{theo}{Theorem}{Theorems}

%new lemma environment
newenvironment{lem}{%
refstepcounter{theo}
tikz[baseline=(current bounding box.east),outer sep=0pt]
node[anchor=east,rectangle,fill=blue!20]
{strut textbf{Lemma~thetheo.}};
newline
}

begin{document}
begin{theo}label{thrm}
Just some text.
end{theo}

begin{lem}label{lm1}
Just some more text.
end{lem}

begin{lem}label[Lemma]{lm2}
Just some more text.
end{lem}

noindent
cref{thrm}\ %give Theorem 0.1
cref{lm1}\ %give Lemma 0.2
cref{lm2}\ %give Lemma 0.3
end{document}


At the bottom of the example I use cref three times. In a comment I display the desired output.
Here I used crefname{theo}{Theorem}{Theorems} to give the "theo"-environment the correct name, as you can see then the "lem"-environment gets the same name, when referred to. The second time I use the "lem"-environment, I label it using label[Lemma]{lm2}, which turns out not to have the desired effect.



(Note: The code that uses tikz is not relevant, I added it as a small justification for not using the newtheorem command instead.)







cleveref






share|improve this question







New contributor




lamcar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




lamcar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




lamcar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 7 hours ago









lamcarlamcar

454




454




New contributor




lamcar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





lamcar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






lamcar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • You could add a boolean to the environment, which would be set to true for only one of the environments and use a test in the command crefname{...}{...} to determine what to print.

    – Bernard
    6 hours ago








  • 1





    never end a paragraph with newline

    – David Carlisle
    6 hours ago



















  • You could add a boolean to the environment, which would be set to true for only one of the environments and use a test in the command crefname{...}{...} to determine what to print.

    – Bernard
    6 hours ago








  • 1





    never end a paragraph with newline

    – David Carlisle
    6 hours ago

















You could add a boolean to the environment, which would be set to true for only one of the environments and use a test in the command crefname{...}{...} to determine what to print.

– Bernard
6 hours ago







You could add a boolean to the environment, which would be set to true for only one of the environments and use a test in the command crefname{...}{...} to determine what to print.

– Bernard
6 hours ago






1




1





never end a paragraph with newline

– David Carlisle
6 hours ago





never end a paragraph with newline

– David Carlisle
6 hours ago










2 Answers
2






active

oldest

votes


















4














You can allocate lem and theo to the same count register (with care:-)



enter image description here



documentclass{article}
usepackage[colorlinks, linkcolor=blue]{hyperref}
usepackage[noabbrev, capitalise]{cleveref}
usepackage{tikz}

%new theorem environment
newcounter{theo}[section]setcounter{theo}{0}
renewcommand{thetheo}{arabic{section}.arabic{theo}}
newenvironment{theo}{%
refstepcounter{theo}%
tikz[baseline=(current bounding box.east),outer sep=0pt]
node[anchor=east,rectangle,fill=green!20]
{strut textbf{Theorem~thetheo.}};
newline%BADNESS 10000!!!!!
}

makeatletter
letc@lemc@theo
%now def not let so it picks up current value
defp@lem{p@theo}
defthelem{thetheo}
makeatother
crefname{theo}{Theorem}{Theorems}
crefname{lem}{Lemma}{Lemmas}

%new lemma environment
newenvironment{lem}{%
refstepcounter{lem}%
tikz[baseline=(current bounding box.east),outer sep=0pt]
node[anchor=east,rectangle,fill=blue!20]
{strut textbf{Lemma~thetheo.}};
newline%BADNESS 10000!!!!!
}

begin{document}
begin{theo}label{thrm}
Just some text.
end{theo}

begin{lem}label{lm1}
Just some more text.
end{lem}

begin{lem}label{lm2}
Just some more text.
end{lem}

noindent
cref{thrm}\ %give Theorem 0.1
cref{lm1}\ %give Lemma 0.2
cref{lm2}\ %give Lemma 0.3
end{document}





share|improve this answer
























  • You may want to point out to the OP that no special effort is needed, so to say, as long as he/she employs either the amsthm or the ntheorem package.

    – Mico
    5 hours ago











  • @Mico I did wonder, but I just answered the question as asked:-) OP should accept your answer though....

    – David Carlisle
    4 hours ago



















2














No need for any programming contortions -- just load either the amsthm or the ntheorem package before both hyperref and cleveref, and then define the theorem-like environments the usual way. In particular, it's perfectly ok for several theorem-like environments to share the same counter (theo in the following code):



enter image description here



documentclass{article}

usepackage{amsthm} %or: usepackage{ntheorem}
usepackage[colorlinks, linkcolor=blue]{hyperref}
usepackage[noabbrev, capitalise]{cleveref}

% two new theorem-like environments
newtheorem{theo}{Theorem}[section] % subordinate 'theo' cntr to 'section' cntr
newtheorem{lem}[theo]{Lemma} % make 'lem' and 'theo' share same cntr

crefname{theo}{Theorem}{Theorems}
crefname{lem}{Lemma}{Lemmas}

begin{document}
setcounter{section}{2} % just for this example

begin{theo}label{thrm}Just some text.end{theo}
begin{lem}label{lm1}Just some more text.end{lem}
begin{lem}label{lm2}Still more text.end{lem}

cref{thrm} dots

cref{lm1,lm2} dots
end{document}





share|improve this answer

























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    lamcar is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478642%2fis-there-a-way-to-make-cleveref-distinguish-two-environments-with-the-same-count%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    You can allocate lem and theo to the same count register (with care:-)



    enter image description here



    documentclass{article}
    usepackage[colorlinks, linkcolor=blue]{hyperref}
    usepackage[noabbrev, capitalise]{cleveref}
    usepackage{tikz}

    %new theorem environment
    newcounter{theo}[section]setcounter{theo}{0}
    renewcommand{thetheo}{arabic{section}.arabic{theo}}
    newenvironment{theo}{%
    refstepcounter{theo}%
    tikz[baseline=(current bounding box.east),outer sep=0pt]
    node[anchor=east,rectangle,fill=green!20]
    {strut textbf{Theorem~thetheo.}};
    newline%BADNESS 10000!!!!!
    }

    makeatletter
    letc@lemc@theo
    %now def not let so it picks up current value
    defp@lem{p@theo}
    defthelem{thetheo}
    makeatother
    crefname{theo}{Theorem}{Theorems}
    crefname{lem}{Lemma}{Lemmas}

    %new lemma environment
    newenvironment{lem}{%
    refstepcounter{lem}%
    tikz[baseline=(current bounding box.east),outer sep=0pt]
    node[anchor=east,rectangle,fill=blue!20]
    {strut textbf{Lemma~thetheo.}};
    newline%BADNESS 10000!!!!!
    }

    begin{document}
    begin{theo}label{thrm}
    Just some text.
    end{theo}

    begin{lem}label{lm1}
    Just some more text.
    end{lem}

    begin{lem}label{lm2}
    Just some more text.
    end{lem}

    noindent
    cref{thrm}\ %give Theorem 0.1
    cref{lm1}\ %give Lemma 0.2
    cref{lm2}\ %give Lemma 0.3
    end{document}





    share|improve this answer
























    • You may want to point out to the OP that no special effort is needed, so to say, as long as he/she employs either the amsthm or the ntheorem package.

      – Mico
      5 hours ago











    • @Mico I did wonder, but I just answered the question as asked:-) OP should accept your answer though....

      – David Carlisle
      4 hours ago
















    4














    You can allocate lem and theo to the same count register (with care:-)



    enter image description here



    documentclass{article}
    usepackage[colorlinks, linkcolor=blue]{hyperref}
    usepackage[noabbrev, capitalise]{cleveref}
    usepackage{tikz}

    %new theorem environment
    newcounter{theo}[section]setcounter{theo}{0}
    renewcommand{thetheo}{arabic{section}.arabic{theo}}
    newenvironment{theo}{%
    refstepcounter{theo}%
    tikz[baseline=(current bounding box.east),outer sep=0pt]
    node[anchor=east,rectangle,fill=green!20]
    {strut textbf{Theorem~thetheo.}};
    newline%BADNESS 10000!!!!!
    }

    makeatletter
    letc@lemc@theo
    %now def not let so it picks up current value
    defp@lem{p@theo}
    defthelem{thetheo}
    makeatother
    crefname{theo}{Theorem}{Theorems}
    crefname{lem}{Lemma}{Lemmas}

    %new lemma environment
    newenvironment{lem}{%
    refstepcounter{lem}%
    tikz[baseline=(current bounding box.east),outer sep=0pt]
    node[anchor=east,rectangle,fill=blue!20]
    {strut textbf{Lemma~thetheo.}};
    newline%BADNESS 10000!!!!!
    }

    begin{document}
    begin{theo}label{thrm}
    Just some text.
    end{theo}

    begin{lem}label{lm1}
    Just some more text.
    end{lem}

    begin{lem}label{lm2}
    Just some more text.
    end{lem}

    noindent
    cref{thrm}\ %give Theorem 0.1
    cref{lm1}\ %give Lemma 0.2
    cref{lm2}\ %give Lemma 0.3
    end{document}





    share|improve this answer
























    • You may want to point out to the OP that no special effort is needed, so to say, as long as he/she employs either the amsthm or the ntheorem package.

      – Mico
      5 hours ago











    • @Mico I did wonder, but I just answered the question as asked:-) OP should accept your answer though....

      – David Carlisle
      4 hours ago














    4












    4








    4







    You can allocate lem and theo to the same count register (with care:-)



    enter image description here



    documentclass{article}
    usepackage[colorlinks, linkcolor=blue]{hyperref}
    usepackage[noabbrev, capitalise]{cleveref}
    usepackage{tikz}

    %new theorem environment
    newcounter{theo}[section]setcounter{theo}{0}
    renewcommand{thetheo}{arabic{section}.arabic{theo}}
    newenvironment{theo}{%
    refstepcounter{theo}%
    tikz[baseline=(current bounding box.east),outer sep=0pt]
    node[anchor=east,rectangle,fill=green!20]
    {strut textbf{Theorem~thetheo.}};
    newline%BADNESS 10000!!!!!
    }

    makeatletter
    letc@lemc@theo
    %now def not let so it picks up current value
    defp@lem{p@theo}
    defthelem{thetheo}
    makeatother
    crefname{theo}{Theorem}{Theorems}
    crefname{lem}{Lemma}{Lemmas}

    %new lemma environment
    newenvironment{lem}{%
    refstepcounter{lem}%
    tikz[baseline=(current bounding box.east),outer sep=0pt]
    node[anchor=east,rectangle,fill=blue!20]
    {strut textbf{Lemma~thetheo.}};
    newline%BADNESS 10000!!!!!
    }

    begin{document}
    begin{theo}label{thrm}
    Just some text.
    end{theo}

    begin{lem}label{lm1}
    Just some more text.
    end{lem}

    begin{lem}label{lm2}
    Just some more text.
    end{lem}

    noindent
    cref{thrm}\ %give Theorem 0.1
    cref{lm1}\ %give Lemma 0.2
    cref{lm2}\ %give Lemma 0.3
    end{document}





    share|improve this answer













    You can allocate lem and theo to the same count register (with care:-)



    enter image description here



    documentclass{article}
    usepackage[colorlinks, linkcolor=blue]{hyperref}
    usepackage[noabbrev, capitalise]{cleveref}
    usepackage{tikz}

    %new theorem environment
    newcounter{theo}[section]setcounter{theo}{0}
    renewcommand{thetheo}{arabic{section}.arabic{theo}}
    newenvironment{theo}{%
    refstepcounter{theo}%
    tikz[baseline=(current bounding box.east),outer sep=0pt]
    node[anchor=east,rectangle,fill=green!20]
    {strut textbf{Theorem~thetheo.}};
    newline%BADNESS 10000!!!!!
    }

    makeatletter
    letc@lemc@theo
    %now def not let so it picks up current value
    defp@lem{p@theo}
    defthelem{thetheo}
    makeatother
    crefname{theo}{Theorem}{Theorems}
    crefname{lem}{Lemma}{Lemmas}

    %new lemma environment
    newenvironment{lem}{%
    refstepcounter{lem}%
    tikz[baseline=(current bounding box.east),outer sep=0pt]
    node[anchor=east,rectangle,fill=blue!20]
    {strut textbf{Lemma~thetheo.}};
    newline%BADNESS 10000!!!!!
    }

    begin{document}
    begin{theo}label{thrm}
    Just some text.
    end{theo}

    begin{lem}label{lm1}
    Just some more text.
    end{lem}

    begin{lem}label{lm2}
    Just some more text.
    end{lem}

    noindent
    cref{thrm}\ %give Theorem 0.1
    cref{lm1}\ %give Lemma 0.2
    cref{lm2}\ %give Lemma 0.3
    end{document}






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 6 hours ago









    David CarlisleDavid Carlisle

    494k4111371885




    494k4111371885













    • You may want to point out to the OP that no special effort is needed, so to say, as long as he/she employs either the amsthm or the ntheorem package.

      – Mico
      5 hours ago











    • @Mico I did wonder, but I just answered the question as asked:-) OP should accept your answer though....

      – David Carlisle
      4 hours ago



















    • You may want to point out to the OP that no special effort is needed, so to say, as long as he/she employs either the amsthm or the ntheorem package.

      – Mico
      5 hours ago











    • @Mico I did wonder, but I just answered the question as asked:-) OP should accept your answer though....

      – David Carlisle
      4 hours ago

















    You may want to point out to the OP that no special effort is needed, so to say, as long as he/she employs either the amsthm or the ntheorem package.

    – Mico
    5 hours ago





    You may want to point out to the OP that no special effort is needed, so to say, as long as he/she employs either the amsthm or the ntheorem package.

    – Mico
    5 hours ago













    @Mico I did wonder, but I just answered the question as asked:-) OP should accept your answer though....

    – David Carlisle
    4 hours ago





    @Mico I did wonder, but I just answered the question as asked:-) OP should accept your answer though....

    – David Carlisle
    4 hours ago











    2














    No need for any programming contortions -- just load either the amsthm or the ntheorem package before both hyperref and cleveref, and then define the theorem-like environments the usual way. In particular, it's perfectly ok for several theorem-like environments to share the same counter (theo in the following code):



    enter image description here



    documentclass{article}

    usepackage{amsthm} %or: usepackage{ntheorem}
    usepackage[colorlinks, linkcolor=blue]{hyperref}
    usepackage[noabbrev, capitalise]{cleveref}

    % two new theorem-like environments
    newtheorem{theo}{Theorem}[section] % subordinate 'theo' cntr to 'section' cntr
    newtheorem{lem}[theo]{Lemma} % make 'lem' and 'theo' share same cntr

    crefname{theo}{Theorem}{Theorems}
    crefname{lem}{Lemma}{Lemmas}

    begin{document}
    setcounter{section}{2} % just for this example

    begin{theo}label{thrm}Just some text.end{theo}
    begin{lem}label{lm1}Just some more text.end{lem}
    begin{lem}label{lm2}Still more text.end{lem}

    cref{thrm} dots

    cref{lm1,lm2} dots
    end{document}





    share|improve this answer






























      2














      No need for any programming contortions -- just load either the amsthm or the ntheorem package before both hyperref and cleveref, and then define the theorem-like environments the usual way. In particular, it's perfectly ok for several theorem-like environments to share the same counter (theo in the following code):



      enter image description here



      documentclass{article}

      usepackage{amsthm} %or: usepackage{ntheorem}
      usepackage[colorlinks, linkcolor=blue]{hyperref}
      usepackage[noabbrev, capitalise]{cleveref}

      % two new theorem-like environments
      newtheorem{theo}{Theorem}[section] % subordinate 'theo' cntr to 'section' cntr
      newtheorem{lem}[theo]{Lemma} % make 'lem' and 'theo' share same cntr

      crefname{theo}{Theorem}{Theorems}
      crefname{lem}{Lemma}{Lemmas}

      begin{document}
      setcounter{section}{2} % just for this example

      begin{theo}label{thrm}Just some text.end{theo}
      begin{lem}label{lm1}Just some more text.end{lem}
      begin{lem}label{lm2}Still more text.end{lem}

      cref{thrm} dots

      cref{lm1,lm2} dots
      end{document}





      share|improve this answer




























        2












        2








        2







        No need for any programming contortions -- just load either the amsthm or the ntheorem package before both hyperref and cleveref, and then define the theorem-like environments the usual way. In particular, it's perfectly ok for several theorem-like environments to share the same counter (theo in the following code):



        enter image description here



        documentclass{article}

        usepackage{amsthm} %or: usepackage{ntheorem}
        usepackage[colorlinks, linkcolor=blue]{hyperref}
        usepackage[noabbrev, capitalise]{cleveref}

        % two new theorem-like environments
        newtheorem{theo}{Theorem}[section] % subordinate 'theo' cntr to 'section' cntr
        newtheorem{lem}[theo]{Lemma} % make 'lem' and 'theo' share same cntr

        crefname{theo}{Theorem}{Theorems}
        crefname{lem}{Lemma}{Lemmas}

        begin{document}
        setcounter{section}{2} % just for this example

        begin{theo}label{thrm}Just some text.end{theo}
        begin{lem}label{lm1}Just some more text.end{lem}
        begin{lem}label{lm2}Still more text.end{lem}

        cref{thrm} dots

        cref{lm1,lm2} dots
        end{document}





        share|improve this answer















        No need for any programming contortions -- just load either the amsthm or the ntheorem package before both hyperref and cleveref, and then define the theorem-like environments the usual way. In particular, it's perfectly ok for several theorem-like environments to share the same counter (theo in the following code):



        enter image description here



        documentclass{article}

        usepackage{amsthm} %or: usepackage{ntheorem}
        usepackage[colorlinks, linkcolor=blue]{hyperref}
        usepackage[noabbrev, capitalise]{cleveref}

        % two new theorem-like environments
        newtheorem{theo}{Theorem}[section] % subordinate 'theo' cntr to 'section' cntr
        newtheorem{lem}[theo]{Lemma} % make 'lem' and 'theo' share same cntr

        crefname{theo}{Theorem}{Theorems}
        crefname{lem}{Lemma}{Lemmas}

        begin{document}
        setcounter{section}{2} % just for this example

        begin{theo}label{thrm}Just some text.end{theo}
        begin{lem}label{lm1}Just some more text.end{lem}
        begin{lem}label{lm2}Still more text.end{lem}

        cref{thrm} dots

        cref{lm1,lm2} dots
        end{document}






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 5 hours ago

























        answered 5 hours ago









        MicoMico

        282k31385774




        282k31385774






















            lamcar is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            lamcar is a new contributor. Be nice, and check out our Code of Conduct.













            lamcar is a new contributor. Be nice, and check out our Code of Conduct.












            lamcar is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478642%2fis-there-a-way-to-make-cleveref-distinguish-two-environments-with-the-same-count%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            數位音樂下載

            格利澤436b

            When can things happen in Etherscan, such as the picture below?