Consecutive numbering and labels in tcolorbox
Those days I write a book, and I use framed boxes tcolorbox
. Have a look:
documentclass[12pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage{amsmath,amsthm,amsfonts,amssymb,mathtools}
usepackage[english]{babel}
usepackage{graphicx}
usepackage{textcomp}
usepackage{tcolorbox,xcolor}
theoremstyle{definition}
makeatletter
tcbuselibrary{theorems}
newtcbtheorem[number within=section]{mytheo}{Theorem}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{myprop}{Proposition}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{mylem}{Lemma}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{mypor}{Corollary}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{myax}{Axiom}%
{colback=black!5,colframe=blue!35!black,fonttitle=bfseries}{th}
renewcommand{rmdefault}{udidot}
begin{document}
newtheorem{defin}{Definition}[section]
newtheorem{prt}{Remark}[section]
newtheorem{prts}{Remarks}[section]
newtheorem{exmp}{Example}[section]
newtheorem{exmps}{Examples}[section]
newtheorem*{note}{Note}
chapter{Maximal and Prime Ideals}
section{Maximal Ideals}
begin{defin}
Let $R$ a commutative ring with $1_R$ ...
end{defin}
begin{myprop}{Maximal Ideals Criterion}{}
label{Max Id Crit}
Let $R$ a commutative ring with $1_R$ ...
end{myprop}
From the Proposition ref{Max Id Crit}, ...
end{document}
As you can see, I would like to use these frames only for theorems, propositions, lemmas, corollaries and axioms (and not for the definitions). Also I would like to keep the choice to write some of them (for instance, a theorem) without these frames.
My questions are:
- How can we have consecutive numbering in the whole text?
- Ase you can see, we face a problem with labels in the reference of theorems etc. How can we solve it?
cross-referencing numbering tcolorbox labels
add a comment |
Those days I write a book, and I use framed boxes tcolorbox
. Have a look:
documentclass[12pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage{amsmath,amsthm,amsfonts,amssymb,mathtools}
usepackage[english]{babel}
usepackage{graphicx}
usepackage{textcomp}
usepackage{tcolorbox,xcolor}
theoremstyle{definition}
makeatletter
tcbuselibrary{theorems}
newtcbtheorem[number within=section]{mytheo}{Theorem}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{myprop}{Proposition}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{mylem}{Lemma}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{mypor}{Corollary}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{myax}{Axiom}%
{colback=black!5,colframe=blue!35!black,fonttitle=bfseries}{th}
renewcommand{rmdefault}{udidot}
begin{document}
newtheorem{defin}{Definition}[section]
newtheorem{prt}{Remark}[section]
newtheorem{prts}{Remarks}[section]
newtheorem{exmp}{Example}[section]
newtheorem{exmps}{Examples}[section]
newtheorem*{note}{Note}
chapter{Maximal and Prime Ideals}
section{Maximal Ideals}
begin{defin}
Let $R$ a commutative ring with $1_R$ ...
end{defin}
begin{myprop}{Maximal Ideals Criterion}{}
label{Max Id Crit}
Let $R$ a commutative ring with $1_R$ ...
end{myprop}
From the Proposition ref{Max Id Crit}, ...
end{document}
As you can see, I would like to use these frames only for theorems, propositions, lemmas, corollaries and axioms (and not for the definitions). Also I would like to keep the choice to write some of them (for instance, a theorem) without these frames.
My questions are:
- How can we have consecutive numbering in the whole text?
- Ase you can see, we face a problem with labels in the reference of theorems etc. How can we solve it?
cross-referencing numbering tcolorbox labels
add a comment |
Those days I write a book, and I use framed boxes tcolorbox
. Have a look:
documentclass[12pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage{amsmath,amsthm,amsfonts,amssymb,mathtools}
usepackage[english]{babel}
usepackage{graphicx}
usepackage{textcomp}
usepackage{tcolorbox,xcolor}
theoremstyle{definition}
makeatletter
tcbuselibrary{theorems}
newtcbtheorem[number within=section]{mytheo}{Theorem}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{myprop}{Proposition}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{mylem}{Lemma}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{mypor}{Corollary}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{myax}{Axiom}%
{colback=black!5,colframe=blue!35!black,fonttitle=bfseries}{th}
renewcommand{rmdefault}{udidot}
begin{document}
newtheorem{defin}{Definition}[section]
newtheorem{prt}{Remark}[section]
newtheorem{prts}{Remarks}[section]
newtheorem{exmp}{Example}[section]
newtheorem{exmps}{Examples}[section]
newtheorem*{note}{Note}
chapter{Maximal and Prime Ideals}
section{Maximal Ideals}
begin{defin}
Let $R$ a commutative ring with $1_R$ ...
end{defin}
begin{myprop}{Maximal Ideals Criterion}{}
label{Max Id Crit}
Let $R$ a commutative ring with $1_R$ ...
end{myprop}
From the Proposition ref{Max Id Crit}, ...
end{document}
As you can see, I would like to use these frames only for theorems, propositions, lemmas, corollaries and axioms (and not for the definitions). Also I would like to keep the choice to write some of them (for instance, a theorem) without these frames.
My questions are:
- How can we have consecutive numbering in the whole text?
- Ase you can see, we face a problem with labels in the reference of theorems etc. How can we solve it?
cross-referencing numbering tcolorbox labels
Those days I write a book, and I use framed boxes tcolorbox
. Have a look:
documentclass[12pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage{amsmath,amsthm,amsfonts,amssymb,mathtools}
usepackage[english]{babel}
usepackage{graphicx}
usepackage{textcomp}
usepackage{tcolorbox,xcolor}
theoremstyle{definition}
makeatletter
tcbuselibrary{theorems}
newtcbtheorem[number within=section]{mytheo}{Theorem}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{myprop}{Proposition}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{mylem}{Lemma}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{mypor}{Corollary}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{myax}{Axiom}%
{colback=black!5,colframe=blue!35!black,fonttitle=bfseries}{th}
renewcommand{rmdefault}{udidot}
begin{document}
newtheorem{defin}{Definition}[section]
newtheorem{prt}{Remark}[section]
newtheorem{prts}{Remarks}[section]
newtheorem{exmp}{Example}[section]
newtheorem{exmps}{Examples}[section]
newtheorem*{note}{Note}
chapter{Maximal and Prime Ideals}
section{Maximal Ideals}
begin{defin}
Let $R$ a commutative ring with $1_R$ ...
end{defin}
begin{myprop}{Maximal Ideals Criterion}{}
label{Max Id Crit}
Let $R$ a commutative ring with $1_R$ ...
end{myprop}
From the Proposition ref{Max Id Crit}, ...
end{document}
As you can see, I would like to use these frames only for theorems, propositions, lemmas, corollaries and axioms (and not for the definitions). Also I would like to keep the choice to write some of them (for instance, a theorem) without these frames.
My questions are:
- How can we have consecutive numbering in the whole text?
- Ase you can see, we face a problem with labels in the reference of theorems etc. How can we solve it?
cross-referencing numbering tcolorbox labels
cross-referencing numbering tcolorbox labels
asked 8 hours ago
ChrisChris
1506
1506
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
- The tcbtheorem environments allow you to use counters from other tcbtheorems as well as existing LaTeX counters. It will be easier to define the standard LaTeX theorems first (all sharing the same counter), and then define the tcbtheorems (using that same counter).
- The problem is that a label for a tcbtheorem environment needs to be passed as an option to that environment in order for it to work correctly. This is not standard LaTeX behaviour (you would have noticed that labelling and referencing your definition environment would have worked without a hitch).
documentclass[12pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage{amsmath,amsthm,amsfonts,amssymb,mathtools}
usepackage[english]{babel}
usepackage{graphicx}
usepackage{textcomp}
usepackage{tcolorbox,xcolor}
theoremstyle{definition}
% Define amsthm theorems first
newtheorem{defin}{Definition}[section] % Creates a new counter, number within section
newtheorem{prt}[defin]{Remark} % Putting [defin] in second position uses defin's counter instead of creating a new one
newtheorem{prts}[defin]{Remarks} % Again share defin's counter
newtheorem{exmp}[defin]{Example} % etc.
newtheorem{exmps}[defin]{Examples}
newtheorem*{note}{Note}
tcbuselibrary{theorems}
% use counter*=defin to make each tcbtheorem share defin's counter
newtcbtheorem[use counter*=defin, number within=section]{mytheo}{Theorem}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{myprop}{Proposition}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{mylem}{Lemma}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{mypor}{Corollary}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{myax}{Axiom}%
{colback=black!5,colframe=blue!35!black,fonttitle=bfseries}{th}
renewcommand{rmdefault}{udidot}
begin{document}
chapter{Maximal and Prime Ideals}
section{Maximal Ideals}
% Normal labelling
begin{defin} label{first_def}
Let $R$ a commutative ring with $1_R$ ...
end{defin}
% tcbtheorem labelling
begin{myprop}[label=prop:maximal]{Maximal Ideals Criterion}{}
Let $R$ a commutative ring with $1_R$ ...
end{myprop}
From the Proposition ref{prop:maximal} and definition ref{first_def}ldots
end{document}
Output:
As an aside, I would recommend using the cleveref
package which can easily be set-up with the each tcbtheorem so as to produce a named reference instead of just a number e.g. 'proposition 1.1.2' vs '1.1.2'. That way you don't have to worry about whether you're referencing a theorem, or a definition, or a proposition etc. each time.
FYI There was a rogue makeatletter
in your code.
Works perfect, thank you. But, why makeatletter is a rogue?
– Chris
6 hours ago
add a comment |
The key is the tcolorbox options use counter=<another counter>
and use counter from= <counter from another tcolorbox>
Update taking into account the OP comments:
documentclass[12pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage{amsmath,amsthm,amsfonts,amssymb,mathtools}
usepackage[english]{babel}
usepackage{graphicx}
usepackage{textcomp}
usepackage{tcolorbox,xcolor}
theoremstyle{definition}
%makeatletter
tcbuselibrary{theorems}
newtcbtheorem[number within=section,use counter=defin]{mytheo}{Theorem}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter =defin]{myprop}{Proposition}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter= defin]{mylem}{Lemma}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter=defin]{mycor}{Corollary}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter=defin]{myax}{Axiom}%
{colback=black!5,colframe=blue!35!black,fonttitle=bfseries}{th}
renewcommand{rmdefault}{udidot}
begin{document}
newtheorem{defin}{Definition}[section]
newtheorem{prt}[defin]{Remark}
newtheorem{prts}[defin]{Remarks}
newtheorem{exmp}[defin]{Example}%[section]
newtheorem{exmps}[defin]{Examples}
newtheorem*{note}{Note}
chapter{Maximal and Prime Ideals}
section{Maximal Ideals}
begin{defin}
label{def:commutative ring}
Let $R$ a commutative ring with $1_R$ ...
end{defin}
begin{myprop}{Maximal Ideals Criterion}{Max Id Crit}
Let $R$ a commutative ring with $1_R$ ...
end{myprop}
From the Proposition ref{th:Max Id Crit},
See definition ref{def:commutative ring}
begin{exmp} label{ex: my example}
my example
end{exmp}
example : ref{ex: my example}
end{document}
Thank you very much for your comment. It works nice, but I have one more question. How do we refer to a non framed definition or proposition etc? Normally with "label{}"?
– Chris
6 hours ago
1
@Chris Do you mean a definition created by anewtheorem
or by anewtcbtheorem
?
– Hafid Boukhoulda
6 hours ago
From newtheorem :)
– Chris
6 hours ago
1
@Chrislabel{mylabel}
thenref{mylabel}
where mylabel can be replaced with something like def:commutative ring
– Hafid Boukhoulda
6 hours ago
1
@Chris answer updated
– Hafid Boukhoulda
5 hours ago
|
show 3 more comments
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
});
}
});
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%2f474757%2fconsecutive-numbering-and-labels-in-tcolorbox%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
- The tcbtheorem environments allow you to use counters from other tcbtheorems as well as existing LaTeX counters. It will be easier to define the standard LaTeX theorems first (all sharing the same counter), and then define the tcbtheorems (using that same counter).
- The problem is that a label for a tcbtheorem environment needs to be passed as an option to that environment in order for it to work correctly. This is not standard LaTeX behaviour (you would have noticed that labelling and referencing your definition environment would have worked without a hitch).
documentclass[12pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage{amsmath,amsthm,amsfonts,amssymb,mathtools}
usepackage[english]{babel}
usepackage{graphicx}
usepackage{textcomp}
usepackage{tcolorbox,xcolor}
theoremstyle{definition}
% Define amsthm theorems first
newtheorem{defin}{Definition}[section] % Creates a new counter, number within section
newtheorem{prt}[defin]{Remark} % Putting [defin] in second position uses defin's counter instead of creating a new one
newtheorem{prts}[defin]{Remarks} % Again share defin's counter
newtheorem{exmp}[defin]{Example} % etc.
newtheorem{exmps}[defin]{Examples}
newtheorem*{note}{Note}
tcbuselibrary{theorems}
% use counter*=defin to make each tcbtheorem share defin's counter
newtcbtheorem[use counter*=defin, number within=section]{mytheo}{Theorem}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{myprop}{Proposition}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{mylem}{Lemma}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{mypor}{Corollary}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{myax}{Axiom}%
{colback=black!5,colframe=blue!35!black,fonttitle=bfseries}{th}
renewcommand{rmdefault}{udidot}
begin{document}
chapter{Maximal and Prime Ideals}
section{Maximal Ideals}
% Normal labelling
begin{defin} label{first_def}
Let $R$ a commutative ring with $1_R$ ...
end{defin}
% tcbtheorem labelling
begin{myprop}[label=prop:maximal]{Maximal Ideals Criterion}{}
Let $R$ a commutative ring with $1_R$ ...
end{myprop}
From the Proposition ref{prop:maximal} and definition ref{first_def}ldots
end{document}
Output:
As an aside, I would recommend using the cleveref
package which can easily be set-up with the each tcbtheorem so as to produce a named reference instead of just a number e.g. 'proposition 1.1.2' vs '1.1.2'. That way you don't have to worry about whether you're referencing a theorem, or a definition, or a proposition etc. each time.
FYI There was a rogue makeatletter
in your code.
Works perfect, thank you. But, why makeatletter is a rogue?
– Chris
6 hours ago
add a comment |
- The tcbtheorem environments allow you to use counters from other tcbtheorems as well as existing LaTeX counters. It will be easier to define the standard LaTeX theorems first (all sharing the same counter), and then define the tcbtheorems (using that same counter).
- The problem is that a label for a tcbtheorem environment needs to be passed as an option to that environment in order for it to work correctly. This is not standard LaTeX behaviour (you would have noticed that labelling and referencing your definition environment would have worked without a hitch).
documentclass[12pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage{amsmath,amsthm,amsfonts,amssymb,mathtools}
usepackage[english]{babel}
usepackage{graphicx}
usepackage{textcomp}
usepackage{tcolorbox,xcolor}
theoremstyle{definition}
% Define amsthm theorems first
newtheorem{defin}{Definition}[section] % Creates a new counter, number within section
newtheorem{prt}[defin]{Remark} % Putting [defin] in second position uses defin's counter instead of creating a new one
newtheorem{prts}[defin]{Remarks} % Again share defin's counter
newtheorem{exmp}[defin]{Example} % etc.
newtheorem{exmps}[defin]{Examples}
newtheorem*{note}{Note}
tcbuselibrary{theorems}
% use counter*=defin to make each tcbtheorem share defin's counter
newtcbtheorem[use counter*=defin, number within=section]{mytheo}{Theorem}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{myprop}{Proposition}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{mylem}{Lemma}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{mypor}{Corollary}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{myax}{Axiom}%
{colback=black!5,colframe=blue!35!black,fonttitle=bfseries}{th}
renewcommand{rmdefault}{udidot}
begin{document}
chapter{Maximal and Prime Ideals}
section{Maximal Ideals}
% Normal labelling
begin{defin} label{first_def}
Let $R$ a commutative ring with $1_R$ ...
end{defin}
% tcbtheorem labelling
begin{myprop}[label=prop:maximal]{Maximal Ideals Criterion}{}
Let $R$ a commutative ring with $1_R$ ...
end{myprop}
From the Proposition ref{prop:maximal} and definition ref{first_def}ldots
end{document}
Output:
As an aside, I would recommend using the cleveref
package which can easily be set-up with the each tcbtheorem so as to produce a named reference instead of just a number e.g. 'proposition 1.1.2' vs '1.1.2'. That way you don't have to worry about whether you're referencing a theorem, or a definition, or a proposition etc. each time.
FYI There was a rogue makeatletter
in your code.
Works perfect, thank you. But, why makeatletter is a rogue?
– Chris
6 hours ago
add a comment |
- The tcbtheorem environments allow you to use counters from other tcbtheorems as well as existing LaTeX counters. It will be easier to define the standard LaTeX theorems first (all sharing the same counter), and then define the tcbtheorems (using that same counter).
- The problem is that a label for a tcbtheorem environment needs to be passed as an option to that environment in order for it to work correctly. This is not standard LaTeX behaviour (you would have noticed that labelling and referencing your definition environment would have worked without a hitch).
documentclass[12pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage{amsmath,amsthm,amsfonts,amssymb,mathtools}
usepackage[english]{babel}
usepackage{graphicx}
usepackage{textcomp}
usepackage{tcolorbox,xcolor}
theoremstyle{definition}
% Define amsthm theorems first
newtheorem{defin}{Definition}[section] % Creates a new counter, number within section
newtheorem{prt}[defin]{Remark} % Putting [defin] in second position uses defin's counter instead of creating a new one
newtheorem{prts}[defin]{Remarks} % Again share defin's counter
newtheorem{exmp}[defin]{Example} % etc.
newtheorem{exmps}[defin]{Examples}
newtheorem*{note}{Note}
tcbuselibrary{theorems}
% use counter*=defin to make each tcbtheorem share defin's counter
newtcbtheorem[use counter*=defin, number within=section]{mytheo}{Theorem}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{myprop}{Proposition}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{mylem}{Lemma}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{mypor}{Corollary}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{myax}{Axiom}%
{colback=black!5,colframe=blue!35!black,fonttitle=bfseries}{th}
renewcommand{rmdefault}{udidot}
begin{document}
chapter{Maximal and Prime Ideals}
section{Maximal Ideals}
% Normal labelling
begin{defin} label{first_def}
Let $R$ a commutative ring with $1_R$ ...
end{defin}
% tcbtheorem labelling
begin{myprop}[label=prop:maximal]{Maximal Ideals Criterion}{}
Let $R$ a commutative ring with $1_R$ ...
end{myprop}
From the Proposition ref{prop:maximal} and definition ref{first_def}ldots
end{document}
Output:
As an aside, I would recommend using the cleveref
package which can easily be set-up with the each tcbtheorem so as to produce a named reference instead of just a number e.g. 'proposition 1.1.2' vs '1.1.2'. That way you don't have to worry about whether you're referencing a theorem, or a definition, or a proposition etc. each time.
FYI There was a rogue makeatletter
in your code.
- The tcbtheorem environments allow you to use counters from other tcbtheorems as well as existing LaTeX counters. It will be easier to define the standard LaTeX theorems first (all sharing the same counter), and then define the tcbtheorems (using that same counter).
- The problem is that a label for a tcbtheorem environment needs to be passed as an option to that environment in order for it to work correctly. This is not standard LaTeX behaviour (you would have noticed that labelling and referencing your definition environment would have worked without a hitch).
documentclass[12pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage{amsmath,amsthm,amsfonts,amssymb,mathtools}
usepackage[english]{babel}
usepackage{graphicx}
usepackage{textcomp}
usepackage{tcolorbox,xcolor}
theoremstyle{definition}
% Define amsthm theorems first
newtheorem{defin}{Definition}[section] % Creates a new counter, number within section
newtheorem{prt}[defin]{Remark} % Putting [defin] in second position uses defin's counter instead of creating a new one
newtheorem{prts}[defin]{Remarks} % Again share defin's counter
newtheorem{exmp}[defin]{Example} % etc.
newtheorem{exmps}[defin]{Examples}
newtheorem*{note}{Note}
tcbuselibrary{theorems}
% use counter*=defin to make each tcbtheorem share defin's counter
newtcbtheorem[use counter*=defin, number within=section]{mytheo}{Theorem}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{myprop}{Proposition}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{mylem}{Lemma}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{mypor}{Corollary}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[use counter*=defin, number within=section]{myax}{Axiom}%
{colback=black!5,colframe=blue!35!black,fonttitle=bfseries}{th}
renewcommand{rmdefault}{udidot}
begin{document}
chapter{Maximal and Prime Ideals}
section{Maximal Ideals}
% Normal labelling
begin{defin} label{first_def}
Let $R$ a commutative ring with $1_R$ ...
end{defin}
% tcbtheorem labelling
begin{myprop}[label=prop:maximal]{Maximal Ideals Criterion}{}
Let $R$ a commutative ring with $1_R$ ...
end{myprop}
From the Proposition ref{prop:maximal} and definition ref{first_def}ldots
end{document}
Output:
As an aside, I would recommend using the cleveref
package which can easily be set-up with the each tcbtheorem so as to produce a named reference instead of just a number e.g. 'proposition 1.1.2' vs '1.1.2'. That way you don't have to worry about whether you're referencing a theorem, or a definition, or a proposition etc. each time.
FYI There was a rogue makeatletter
in your code.
edited 7 hours ago
answered 7 hours ago
Pippip19Pippip19
6387
6387
Works perfect, thank you. But, why makeatletter is a rogue?
– Chris
6 hours ago
add a comment |
Works perfect, thank you. But, why makeatletter is a rogue?
– Chris
6 hours ago
Works perfect, thank you. But, why makeatletter is a rogue?
– Chris
6 hours ago
Works perfect, thank you. But, why makeatletter is a rogue?
– Chris
6 hours ago
add a comment |
The key is the tcolorbox options use counter=<another counter>
and use counter from= <counter from another tcolorbox>
Update taking into account the OP comments:
documentclass[12pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage{amsmath,amsthm,amsfonts,amssymb,mathtools}
usepackage[english]{babel}
usepackage{graphicx}
usepackage{textcomp}
usepackage{tcolorbox,xcolor}
theoremstyle{definition}
%makeatletter
tcbuselibrary{theorems}
newtcbtheorem[number within=section,use counter=defin]{mytheo}{Theorem}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter =defin]{myprop}{Proposition}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter= defin]{mylem}{Lemma}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter=defin]{mycor}{Corollary}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter=defin]{myax}{Axiom}%
{colback=black!5,colframe=blue!35!black,fonttitle=bfseries}{th}
renewcommand{rmdefault}{udidot}
begin{document}
newtheorem{defin}{Definition}[section]
newtheorem{prt}[defin]{Remark}
newtheorem{prts}[defin]{Remarks}
newtheorem{exmp}[defin]{Example}%[section]
newtheorem{exmps}[defin]{Examples}
newtheorem*{note}{Note}
chapter{Maximal and Prime Ideals}
section{Maximal Ideals}
begin{defin}
label{def:commutative ring}
Let $R$ a commutative ring with $1_R$ ...
end{defin}
begin{myprop}{Maximal Ideals Criterion}{Max Id Crit}
Let $R$ a commutative ring with $1_R$ ...
end{myprop}
From the Proposition ref{th:Max Id Crit},
See definition ref{def:commutative ring}
begin{exmp} label{ex: my example}
my example
end{exmp}
example : ref{ex: my example}
end{document}
Thank you very much for your comment. It works nice, but I have one more question. How do we refer to a non framed definition or proposition etc? Normally with "label{}"?
– Chris
6 hours ago
1
@Chris Do you mean a definition created by anewtheorem
or by anewtcbtheorem
?
– Hafid Boukhoulda
6 hours ago
From newtheorem :)
– Chris
6 hours ago
1
@Chrislabel{mylabel}
thenref{mylabel}
where mylabel can be replaced with something like def:commutative ring
– Hafid Boukhoulda
6 hours ago
1
@Chris answer updated
– Hafid Boukhoulda
5 hours ago
|
show 3 more comments
The key is the tcolorbox options use counter=<another counter>
and use counter from= <counter from another tcolorbox>
Update taking into account the OP comments:
documentclass[12pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage{amsmath,amsthm,amsfonts,amssymb,mathtools}
usepackage[english]{babel}
usepackage{graphicx}
usepackage{textcomp}
usepackage{tcolorbox,xcolor}
theoremstyle{definition}
%makeatletter
tcbuselibrary{theorems}
newtcbtheorem[number within=section,use counter=defin]{mytheo}{Theorem}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter =defin]{myprop}{Proposition}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter= defin]{mylem}{Lemma}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter=defin]{mycor}{Corollary}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter=defin]{myax}{Axiom}%
{colback=black!5,colframe=blue!35!black,fonttitle=bfseries}{th}
renewcommand{rmdefault}{udidot}
begin{document}
newtheorem{defin}{Definition}[section]
newtheorem{prt}[defin]{Remark}
newtheorem{prts}[defin]{Remarks}
newtheorem{exmp}[defin]{Example}%[section]
newtheorem{exmps}[defin]{Examples}
newtheorem*{note}{Note}
chapter{Maximal and Prime Ideals}
section{Maximal Ideals}
begin{defin}
label{def:commutative ring}
Let $R$ a commutative ring with $1_R$ ...
end{defin}
begin{myprop}{Maximal Ideals Criterion}{Max Id Crit}
Let $R$ a commutative ring with $1_R$ ...
end{myprop}
From the Proposition ref{th:Max Id Crit},
See definition ref{def:commutative ring}
begin{exmp} label{ex: my example}
my example
end{exmp}
example : ref{ex: my example}
end{document}
Thank you very much for your comment. It works nice, but I have one more question. How do we refer to a non framed definition or proposition etc? Normally with "label{}"?
– Chris
6 hours ago
1
@Chris Do you mean a definition created by anewtheorem
or by anewtcbtheorem
?
– Hafid Boukhoulda
6 hours ago
From newtheorem :)
– Chris
6 hours ago
1
@Chrislabel{mylabel}
thenref{mylabel}
where mylabel can be replaced with something like def:commutative ring
– Hafid Boukhoulda
6 hours ago
1
@Chris answer updated
– Hafid Boukhoulda
5 hours ago
|
show 3 more comments
The key is the tcolorbox options use counter=<another counter>
and use counter from= <counter from another tcolorbox>
Update taking into account the OP comments:
documentclass[12pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage{amsmath,amsthm,amsfonts,amssymb,mathtools}
usepackage[english]{babel}
usepackage{graphicx}
usepackage{textcomp}
usepackage{tcolorbox,xcolor}
theoremstyle{definition}
%makeatletter
tcbuselibrary{theorems}
newtcbtheorem[number within=section,use counter=defin]{mytheo}{Theorem}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter =defin]{myprop}{Proposition}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter= defin]{mylem}{Lemma}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter=defin]{mycor}{Corollary}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter=defin]{myax}{Axiom}%
{colback=black!5,colframe=blue!35!black,fonttitle=bfseries}{th}
renewcommand{rmdefault}{udidot}
begin{document}
newtheorem{defin}{Definition}[section]
newtheorem{prt}[defin]{Remark}
newtheorem{prts}[defin]{Remarks}
newtheorem{exmp}[defin]{Example}%[section]
newtheorem{exmps}[defin]{Examples}
newtheorem*{note}{Note}
chapter{Maximal and Prime Ideals}
section{Maximal Ideals}
begin{defin}
label{def:commutative ring}
Let $R$ a commutative ring with $1_R$ ...
end{defin}
begin{myprop}{Maximal Ideals Criterion}{Max Id Crit}
Let $R$ a commutative ring with $1_R$ ...
end{myprop}
From the Proposition ref{th:Max Id Crit},
See definition ref{def:commutative ring}
begin{exmp} label{ex: my example}
my example
end{exmp}
example : ref{ex: my example}
end{document}
The key is the tcolorbox options use counter=<another counter>
and use counter from= <counter from another tcolorbox>
Update taking into account the OP comments:
documentclass[12pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage{amsmath,amsthm,amsfonts,amssymb,mathtools}
usepackage[english]{babel}
usepackage{graphicx}
usepackage{textcomp}
usepackage{tcolorbox,xcolor}
theoremstyle{definition}
%makeatletter
tcbuselibrary{theorems}
newtcbtheorem[number within=section,use counter=defin]{mytheo}{Theorem}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter =defin]{myprop}{Proposition}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter= defin]{mylem}{Lemma}%
{colback=black!5,colframe=red!50!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter=defin]{mycor}{Corollary}%
{colback=black!5,colframe=red!35!black,fonttitle=bfseries}{th}
newtcbtheorem[number within=section,use counter=defin]{myax}{Axiom}%
{colback=black!5,colframe=blue!35!black,fonttitle=bfseries}{th}
renewcommand{rmdefault}{udidot}
begin{document}
newtheorem{defin}{Definition}[section]
newtheorem{prt}[defin]{Remark}
newtheorem{prts}[defin]{Remarks}
newtheorem{exmp}[defin]{Example}%[section]
newtheorem{exmps}[defin]{Examples}
newtheorem*{note}{Note}
chapter{Maximal and Prime Ideals}
section{Maximal Ideals}
begin{defin}
label{def:commutative ring}
Let $R$ a commutative ring with $1_R$ ...
end{defin}
begin{myprop}{Maximal Ideals Criterion}{Max Id Crit}
Let $R$ a commutative ring with $1_R$ ...
end{myprop}
From the Proposition ref{th:Max Id Crit},
See definition ref{def:commutative ring}
begin{exmp} label{ex: my example}
my example
end{exmp}
example : ref{ex: my example}
end{document}
edited 5 hours ago
answered 7 hours ago
Hafid BoukhouldaHafid Boukhoulda
3,3321621
3,3321621
Thank you very much for your comment. It works nice, but I have one more question. How do we refer to a non framed definition or proposition etc? Normally with "label{}"?
– Chris
6 hours ago
1
@Chris Do you mean a definition created by anewtheorem
or by anewtcbtheorem
?
– Hafid Boukhoulda
6 hours ago
From newtheorem :)
– Chris
6 hours ago
1
@Chrislabel{mylabel}
thenref{mylabel}
where mylabel can be replaced with something like def:commutative ring
– Hafid Boukhoulda
6 hours ago
1
@Chris answer updated
– Hafid Boukhoulda
5 hours ago
|
show 3 more comments
Thank you very much for your comment. It works nice, but I have one more question. How do we refer to a non framed definition or proposition etc? Normally with "label{}"?
– Chris
6 hours ago
1
@Chris Do you mean a definition created by anewtheorem
or by anewtcbtheorem
?
– Hafid Boukhoulda
6 hours ago
From newtheorem :)
– Chris
6 hours ago
1
@Chrislabel{mylabel}
thenref{mylabel}
where mylabel can be replaced with something like def:commutative ring
– Hafid Boukhoulda
6 hours ago
1
@Chris answer updated
– Hafid Boukhoulda
5 hours ago
Thank you very much for your comment. It works nice, but I have one more question. How do we refer to a non framed definition or proposition etc? Normally with "label{}"?
– Chris
6 hours ago
Thank you very much for your comment. It works nice, but I have one more question. How do we refer to a non framed definition or proposition etc? Normally with "label{}"?
– Chris
6 hours ago
1
1
@Chris Do you mean a definition created by a
newtheorem
or by a newtcbtheorem
?– Hafid Boukhoulda
6 hours ago
@Chris Do you mean a definition created by a
newtheorem
or by a newtcbtheorem
?– Hafid Boukhoulda
6 hours ago
From newtheorem :)
– Chris
6 hours ago
From newtheorem :)
– Chris
6 hours ago
1
1
@Chris
label{mylabel}
then ref{mylabel}
where mylabel can be replaced with something like def:commutative ring– Hafid Boukhoulda
6 hours ago
@Chris
label{mylabel}
then ref{mylabel}
where mylabel can be replaced with something like def:commutative ring– Hafid Boukhoulda
6 hours ago
1
1
@Chris answer updated
– Hafid Boukhoulda
5 hours ago
@Chris answer updated
– Hafid Boukhoulda
5 hours ago
|
show 3 more comments
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%2f474757%2fconsecutive-numbering-and-labels-in-tcolorbox%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