Is there a way to make cleveref distinguish two environments with the same counter?Cleveref with counters...
Which country has more?
School performs periodic password audits. Is my password compromised?
How to write a chaotic neutral protagonist and prevent my readers from thinking they are evil?
When an outsider describes family relationships, which point of view are they using?
Having the player face themselves after the mid-game
Are these two graphs isomorphic? Why/Why not?
When to use a QR code on a business card?
Cycles on the torus
How can I portion out frozen cookie dough?
How can a demon take control of a human body during REM sleep?
Why do phishing e-mails use faked e-mail addresses instead of the real one?
Under what conditions can the right to be silence be revoked in the USA?
Is this Paypal Github SDK reference really a dangerous site?
Are small insurances worth it?
Professor forcing me to attend a conference, I can't afford even with 50% funding
Boss Telling direct supervisor I snitched
What does the Digital Threat scope actually do?
Is this a submanifold?
What is better: yes / no radio, or simple checkbox?
Why restrict private health insurance?
Sampling from Gaussian mixture models, when are the sampled data independent?
How do I increase the number of TTY consoles?
How do we create new idioms and use them in a novel?
Volume of hyperbola revolved about the y -axis
Is there a way to make cleveref distinguish two environments with the same counter?
Cleveref with counters with same namecleveref counter and ref label number format with padding zeroesTheorem and lemma sharing counter with mdframed and cleverefUsing Cleveref with LIPICs documentclass fails for theorem environments sharing the same countercleveref for theorems with same typeCounter not incrementing when defining crefname with cleveref and algpseudocodeHow can I get cleveref to compress multiple references to the same section?How to show also the name of the parent counter with cleveref?Cleveref and nameinlink – problem with some environments/namesSpecial section names and counter in memoir with cleveref
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
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.
add a comment |
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
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 commandcrefname{...}{...}to determine what to print.
– Bernard
2 hours ago
1
never end a paragraph withnewline
– David Carlisle
1 hour ago
add a comment |
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
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
cleveref
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.
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 2 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 commandcrefname{...}{...}to determine what to print.
– Bernard
2 hours ago
1
never end a paragraph withnewline
– David Carlisle
1 hour ago
add a comment |
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 commandcrefname{...}{...}to determine what to print.
– Bernard
2 hours ago
1
never end a paragraph withnewline
– David Carlisle
1 hour 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
2 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
2 hours ago
1
1
never end a paragraph with
newline– David Carlisle
1 hour ago
never end a paragraph with
newline– David Carlisle
1 hour ago
add a comment |
2 Answers
2
active
oldest
votes
You can allocate lem and theo to the same count register (with care:-)

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}
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 theamsthmor thentheorempackage.
– Mico
1 hour ago
@Mico I did wonder, but I just answered the question as asked:-) OP should accept your answer though....
– David Carlisle
4 mins ago
add a comment |
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):

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}
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
You can allocate lem and theo to the same count register (with care:-)

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}
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 theamsthmor thentheorempackage.
– Mico
1 hour ago
@Mico I did wonder, but I just answered the question as asked:-) OP should accept your answer though....
– David Carlisle
4 mins ago
add a comment |
You can allocate lem and theo to the same count register (with care:-)

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}
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 theamsthmor thentheorempackage.
– Mico
1 hour ago
@Mico I did wonder, but I just answered the question as asked:-) OP should accept your answer though....
– David Carlisle
4 mins ago
add a comment |
You can allocate lem and theo to the same count register (with care:-)

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}
You can allocate lem and theo to the same count register (with care:-)

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}
answered 2 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 theamsthmor thentheorempackage.
– Mico
1 hour ago
@Mico I did wonder, but I just answered the question as asked:-) OP should accept your answer though....
– David Carlisle
4 mins ago
add a comment |
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 theamsthmor thentheorempackage.
– Mico
1 hour ago
@Mico I did wonder, but I just answered the question as asked:-) OP should accept your answer though....
– David Carlisle
4 mins 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
1 hour 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
1 hour ago
@Mico I did wonder, but I just answered the question as asked:-) OP should accept your answer though....
– David Carlisle
4 mins ago
@Mico I did wonder, but I just answered the question as asked:-) OP should accept your answer though....
– David Carlisle
4 mins ago
add a comment |
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):

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}
add a comment |
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):

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}
add a comment |
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):

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}
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):

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}
edited 1 hour ago
answered 1 hour ago
MicoMico
282k31385774
282k31385774
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
2 hours ago
1
never end a paragraph with
newline– David Carlisle
1 hour ago