Theorem numbering in starred sections
up vote
3
down vote
favorite
Let me start with an MWE which illustrates my question.
documentclass{book}
usepackage{amsthm}
newtheorem{theorem}{Theorem}[section]
begin{document}
chapter{Some title}
section{Another title}
begin{theorem}
A nice theorem
end{theorem}
section{Yet another title}
begin{theorem}
Another nice theorem
end{theorem}
section*{Optional section}
begin{theorem}
An optional theorem
end{theorem}
end{document}
The resulting theorem numbers will be
Theorem 1.1.1
Theorem 1.2.2
Theorem 1.2.3.
What I would like to achieve instead is
Theorem 1.1.1
Theorem 1.2.2
Theorem 1.E.1.
In other words, I would like the counter to restart (this I think I can do with setcounter
), but I would like there to be a different symbol for the section counter, like an E for "extra". Should I do this at the level of the section, by redefining thesection
? Or by modifying the theorem
environment (preferably not)? Should I define a new theorem environment (also preferably not)?
I would prefer a systematic solution rather than an ad-hoc approach (where I would need to act separately on each instance of the theorem environment).
Thank you all in advance.
numbering theorems amsthm
add a comment |
up vote
3
down vote
favorite
Let me start with an MWE which illustrates my question.
documentclass{book}
usepackage{amsthm}
newtheorem{theorem}{Theorem}[section]
begin{document}
chapter{Some title}
section{Another title}
begin{theorem}
A nice theorem
end{theorem}
section{Yet another title}
begin{theorem}
Another nice theorem
end{theorem}
section*{Optional section}
begin{theorem}
An optional theorem
end{theorem}
end{document}
The resulting theorem numbers will be
Theorem 1.1.1
Theorem 1.2.2
Theorem 1.2.3.
What I would like to achieve instead is
Theorem 1.1.1
Theorem 1.2.2
Theorem 1.E.1.
In other words, I would like the counter to restart (this I think I can do with setcounter
), but I would like there to be a different symbol for the section counter, like an E for "extra". Should I do this at the level of the section, by redefining thesection
? Or by modifying the theorem
environment (preferably not)? Should I define a new theorem environment (also preferably not)?
I would prefer a systematic solution rather than an ad-hoc approach (where I would need to act separately on each instance of the theorem environment).
Thank you all in advance.
numbering theorems amsthm
i edited the tags to removeamsmath
. theorems are (almost) entirely separate from the math component. i addedamsthm
since that is what you are using in your mwe.
– barbara beeton
2 hours ago
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
Let me start with an MWE which illustrates my question.
documentclass{book}
usepackage{amsthm}
newtheorem{theorem}{Theorem}[section]
begin{document}
chapter{Some title}
section{Another title}
begin{theorem}
A nice theorem
end{theorem}
section{Yet another title}
begin{theorem}
Another nice theorem
end{theorem}
section*{Optional section}
begin{theorem}
An optional theorem
end{theorem}
end{document}
The resulting theorem numbers will be
Theorem 1.1.1
Theorem 1.2.2
Theorem 1.2.3.
What I would like to achieve instead is
Theorem 1.1.1
Theorem 1.2.2
Theorem 1.E.1.
In other words, I would like the counter to restart (this I think I can do with setcounter
), but I would like there to be a different symbol for the section counter, like an E for "extra". Should I do this at the level of the section, by redefining thesection
? Or by modifying the theorem
environment (preferably not)? Should I define a new theorem environment (also preferably not)?
I would prefer a systematic solution rather than an ad-hoc approach (where I would need to act separately on each instance of the theorem environment).
Thank you all in advance.
numbering theorems amsthm
Let me start with an MWE which illustrates my question.
documentclass{book}
usepackage{amsthm}
newtheorem{theorem}{Theorem}[section]
begin{document}
chapter{Some title}
section{Another title}
begin{theorem}
A nice theorem
end{theorem}
section{Yet another title}
begin{theorem}
Another nice theorem
end{theorem}
section*{Optional section}
begin{theorem}
An optional theorem
end{theorem}
end{document}
The resulting theorem numbers will be
Theorem 1.1.1
Theorem 1.2.2
Theorem 1.2.3.
What I would like to achieve instead is
Theorem 1.1.1
Theorem 1.2.2
Theorem 1.E.1.
In other words, I would like the counter to restart (this I think I can do with setcounter
), but I would like there to be a different symbol for the section counter, like an E for "extra". Should I do this at the level of the section, by redefining thesection
? Or by modifying the theorem
environment (preferably not)? Should I define a new theorem environment (also preferably not)?
I would prefer a systematic solution rather than an ad-hoc approach (where I would need to act separately on each instance of the theorem environment).
Thank you all in advance.
numbering theorems amsthm
numbering theorems amsthm
edited 2 hours ago
barbara beeton
68.9k9155367
68.9k9155367
asked 4 hours ago
prt13463
424
424
i edited the tags to removeamsmath
. theorems are (almost) entirely separate from the math component. i addedamsthm
since that is what you are using in your mwe.
– barbara beeton
2 hours ago
add a comment |
i edited the tags to removeamsmath
. theorems are (almost) entirely separate from the math component. i addedamsthm
since that is what you are using in your mwe.
– barbara beeton
2 hours ago
i edited the tags to remove
amsmath
. theorems are (almost) entirely separate from the math component. i added amsthm
since that is what you are using in your mwe.– barbara beeton
2 hours ago
i edited the tags to remove
amsmath
. theorems are (almost) entirely separate from the math component. i added amsthm
since that is what you are using in your mwe.– barbara beeton
2 hours ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
To get this to work you will need to redefine thesection
, which is used as part of the counter in your theorem environment, inside the optional sections and then you will have to reset thesection
at the end of such sections. You can presumably do this with some patchcmd
trickery but an more straightforward approach would be to define a new environment for optional sections that would take care of these changes for you. Doing it this way you would write your optional sections as
begin{section*}{Optional section title}
begin{theorem}
An optional theorem
end{theorem}
end{section*}
Rearranging your MWE so that we have an optional section between two sections, this will have output:
Note that even though the OP says that the theorem numbers should be 1.1.1, 1.E.2, 1.2.3 if the theorems are to be numbered inside sections then, as above, they will be reset each time the section number changes, giving the numbering 1.1.1, 1.E.1, 1.2.1. If the numbering 1.1.1, 1.E.2, 1.2.3 is what is required then replace the line defining the theorem environment with:
newtheorem{theorem}{Theorem}%[section]
numberwithin{theorem}{chapter}% needs usepackage{amsmath}
renewcommandthetheorem{thesection.arabic{theorem}}
and remove setcounter{theorem}{0}
from the section*
environment.
Here is the complete code:
documentclass{book}
usepackage{amsthm}
newenvironment{section*}[1]{% begin{section*}{section title}....end{section*}
section*{#1}
renewcommandthesection{thechapter.E}
setcounter{theorem}{0}}{}
newtheorem{theorem}{Theorem}[section]
begin{document}
chapter{Some title}
section{Another title}
begin{theorem}
A nice theorem
end{theorem}
begin{section*}{Optional section}
begin{theorem}
An optional theorem
end{theorem}
end{section*}
section{Yet another title}
begin{theorem}
Another nice theorem
end{theorem}
end{document}
Edit
As Barbara Beeton suggests in the comments it would be better to give the section*
environment and optional argument to override the E
in the theorem numbers that appear in the optional sections. This is easily done with:
% begin{section*}[label]{section title}....end{section*}
newenvironment{section*}[2][E]{
section*{#2}
renewcommandthesection{thechapter.#1}
setcounter{theorem}{0}}{}
which is used exactly as before if you want the theorems labeled with an E
but to change this to an F
you would use
begin{section*}[F]{Optional section title}
begin{theorem}
An optional theorem
end{theorem}
end{section*}
nice, but on the (not unlikely) assumption that a document will contain more than onesection*
, how about providing for an optional argument that allows the middle element (the letter) to be specified explicitly at the start of that section.
– barbara beeton
2 hours ago
@barbarabeeton Good idea. Done!
– Andrew
25 mins ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
To get this to work you will need to redefine thesection
, which is used as part of the counter in your theorem environment, inside the optional sections and then you will have to reset thesection
at the end of such sections. You can presumably do this with some patchcmd
trickery but an more straightforward approach would be to define a new environment for optional sections that would take care of these changes for you. Doing it this way you would write your optional sections as
begin{section*}{Optional section title}
begin{theorem}
An optional theorem
end{theorem}
end{section*}
Rearranging your MWE so that we have an optional section between two sections, this will have output:
Note that even though the OP says that the theorem numbers should be 1.1.1, 1.E.2, 1.2.3 if the theorems are to be numbered inside sections then, as above, they will be reset each time the section number changes, giving the numbering 1.1.1, 1.E.1, 1.2.1. If the numbering 1.1.1, 1.E.2, 1.2.3 is what is required then replace the line defining the theorem environment with:
newtheorem{theorem}{Theorem}%[section]
numberwithin{theorem}{chapter}% needs usepackage{amsmath}
renewcommandthetheorem{thesection.arabic{theorem}}
and remove setcounter{theorem}{0}
from the section*
environment.
Here is the complete code:
documentclass{book}
usepackage{amsthm}
newenvironment{section*}[1]{% begin{section*}{section title}....end{section*}
section*{#1}
renewcommandthesection{thechapter.E}
setcounter{theorem}{0}}{}
newtheorem{theorem}{Theorem}[section]
begin{document}
chapter{Some title}
section{Another title}
begin{theorem}
A nice theorem
end{theorem}
begin{section*}{Optional section}
begin{theorem}
An optional theorem
end{theorem}
end{section*}
section{Yet another title}
begin{theorem}
Another nice theorem
end{theorem}
end{document}
Edit
As Barbara Beeton suggests in the comments it would be better to give the section*
environment and optional argument to override the E
in the theorem numbers that appear in the optional sections. This is easily done with:
% begin{section*}[label]{section title}....end{section*}
newenvironment{section*}[2][E]{
section*{#2}
renewcommandthesection{thechapter.#1}
setcounter{theorem}{0}}{}
which is used exactly as before if you want the theorems labeled with an E
but to change this to an F
you would use
begin{section*}[F]{Optional section title}
begin{theorem}
An optional theorem
end{theorem}
end{section*}
nice, but on the (not unlikely) assumption that a document will contain more than onesection*
, how about providing for an optional argument that allows the middle element (the letter) to be specified explicitly at the start of that section.
– barbara beeton
2 hours ago
@barbarabeeton Good idea. Done!
– Andrew
25 mins ago
add a comment |
up vote
1
down vote
To get this to work you will need to redefine thesection
, which is used as part of the counter in your theorem environment, inside the optional sections and then you will have to reset thesection
at the end of such sections. You can presumably do this with some patchcmd
trickery but an more straightforward approach would be to define a new environment for optional sections that would take care of these changes for you. Doing it this way you would write your optional sections as
begin{section*}{Optional section title}
begin{theorem}
An optional theorem
end{theorem}
end{section*}
Rearranging your MWE so that we have an optional section between two sections, this will have output:
Note that even though the OP says that the theorem numbers should be 1.1.1, 1.E.2, 1.2.3 if the theorems are to be numbered inside sections then, as above, they will be reset each time the section number changes, giving the numbering 1.1.1, 1.E.1, 1.2.1. If the numbering 1.1.1, 1.E.2, 1.2.3 is what is required then replace the line defining the theorem environment with:
newtheorem{theorem}{Theorem}%[section]
numberwithin{theorem}{chapter}% needs usepackage{amsmath}
renewcommandthetheorem{thesection.arabic{theorem}}
and remove setcounter{theorem}{0}
from the section*
environment.
Here is the complete code:
documentclass{book}
usepackage{amsthm}
newenvironment{section*}[1]{% begin{section*}{section title}....end{section*}
section*{#1}
renewcommandthesection{thechapter.E}
setcounter{theorem}{0}}{}
newtheorem{theorem}{Theorem}[section]
begin{document}
chapter{Some title}
section{Another title}
begin{theorem}
A nice theorem
end{theorem}
begin{section*}{Optional section}
begin{theorem}
An optional theorem
end{theorem}
end{section*}
section{Yet another title}
begin{theorem}
Another nice theorem
end{theorem}
end{document}
Edit
As Barbara Beeton suggests in the comments it would be better to give the section*
environment and optional argument to override the E
in the theorem numbers that appear in the optional sections. This is easily done with:
% begin{section*}[label]{section title}....end{section*}
newenvironment{section*}[2][E]{
section*{#2}
renewcommandthesection{thechapter.#1}
setcounter{theorem}{0}}{}
which is used exactly as before if you want the theorems labeled with an E
but to change this to an F
you would use
begin{section*}[F]{Optional section title}
begin{theorem}
An optional theorem
end{theorem}
end{section*}
nice, but on the (not unlikely) assumption that a document will contain more than onesection*
, how about providing for an optional argument that allows the middle element (the letter) to be specified explicitly at the start of that section.
– barbara beeton
2 hours ago
@barbarabeeton Good idea. Done!
– Andrew
25 mins ago
add a comment |
up vote
1
down vote
up vote
1
down vote
To get this to work you will need to redefine thesection
, which is used as part of the counter in your theorem environment, inside the optional sections and then you will have to reset thesection
at the end of such sections. You can presumably do this with some patchcmd
trickery but an more straightforward approach would be to define a new environment for optional sections that would take care of these changes for you. Doing it this way you would write your optional sections as
begin{section*}{Optional section title}
begin{theorem}
An optional theorem
end{theorem}
end{section*}
Rearranging your MWE so that we have an optional section between two sections, this will have output:
Note that even though the OP says that the theorem numbers should be 1.1.1, 1.E.2, 1.2.3 if the theorems are to be numbered inside sections then, as above, they will be reset each time the section number changes, giving the numbering 1.1.1, 1.E.1, 1.2.1. If the numbering 1.1.1, 1.E.2, 1.2.3 is what is required then replace the line defining the theorem environment with:
newtheorem{theorem}{Theorem}%[section]
numberwithin{theorem}{chapter}% needs usepackage{amsmath}
renewcommandthetheorem{thesection.arabic{theorem}}
and remove setcounter{theorem}{0}
from the section*
environment.
Here is the complete code:
documentclass{book}
usepackage{amsthm}
newenvironment{section*}[1]{% begin{section*}{section title}....end{section*}
section*{#1}
renewcommandthesection{thechapter.E}
setcounter{theorem}{0}}{}
newtheorem{theorem}{Theorem}[section]
begin{document}
chapter{Some title}
section{Another title}
begin{theorem}
A nice theorem
end{theorem}
begin{section*}{Optional section}
begin{theorem}
An optional theorem
end{theorem}
end{section*}
section{Yet another title}
begin{theorem}
Another nice theorem
end{theorem}
end{document}
Edit
As Barbara Beeton suggests in the comments it would be better to give the section*
environment and optional argument to override the E
in the theorem numbers that appear in the optional sections. This is easily done with:
% begin{section*}[label]{section title}....end{section*}
newenvironment{section*}[2][E]{
section*{#2}
renewcommandthesection{thechapter.#1}
setcounter{theorem}{0}}{}
which is used exactly as before if you want the theorems labeled with an E
but to change this to an F
you would use
begin{section*}[F]{Optional section title}
begin{theorem}
An optional theorem
end{theorem}
end{section*}
To get this to work you will need to redefine thesection
, which is used as part of the counter in your theorem environment, inside the optional sections and then you will have to reset thesection
at the end of such sections. You can presumably do this with some patchcmd
trickery but an more straightforward approach would be to define a new environment for optional sections that would take care of these changes for you. Doing it this way you would write your optional sections as
begin{section*}{Optional section title}
begin{theorem}
An optional theorem
end{theorem}
end{section*}
Rearranging your MWE so that we have an optional section between two sections, this will have output:
Note that even though the OP says that the theorem numbers should be 1.1.1, 1.E.2, 1.2.3 if the theorems are to be numbered inside sections then, as above, they will be reset each time the section number changes, giving the numbering 1.1.1, 1.E.1, 1.2.1. If the numbering 1.1.1, 1.E.2, 1.2.3 is what is required then replace the line defining the theorem environment with:
newtheorem{theorem}{Theorem}%[section]
numberwithin{theorem}{chapter}% needs usepackage{amsmath}
renewcommandthetheorem{thesection.arabic{theorem}}
and remove setcounter{theorem}{0}
from the section*
environment.
Here is the complete code:
documentclass{book}
usepackage{amsthm}
newenvironment{section*}[1]{% begin{section*}{section title}....end{section*}
section*{#1}
renewcommandthesection{thechapter.E}
setcounter{theorem}{0}}{}
newtheorem{theorem}{Theorem}[section]
begin{document}
chapter{Some title}
section{Another title}
begin{theorem}
A nice theorem
end{theorem}
begin{section*}{Optional section}
begin{theorem}
An optional theorem
end{theorem}
end{section*}
section{Yet another title}
begin{theorem}
Another nice theorem
end{theorem}
end{document}
Edit
As Barbara Beeton suggests in the comments it would be better to give the section*
environment and optional argument to override the E
in the theorem numbers that appear in the optional sections. This is easily done with:
% begin{section*}[label]{section title}....end{section*}
newenvironment{section*}[2][E]{
section*{#2}
renewcommandthesection{thechapter.#1}
setcounter{theorem}{0}}{}
which is used exactly as before if you want the theorems labeled with an E
but to change this to an F
you would use
begin{section*}[F]{Optional section title}
begin{theorem}
An optional theorem
end{theorem}
end{section*}
edited 25 mins ago
answered 3 hours ago
Andrew
29.9k34380
29.9k34380
nice, but on the (not unlikely) assumption that a document will contain more than onesection*
, how about providing for an optional argument that allows the middle element (the letter) to be specified explicitly at the start of that section.
– barbara beeton
2 hours ago
@barbarabeeton Good idea. Done!
– Andrew
25 mins ago
add a comment |
nice, but on the (not unlikely) assumption that a document will contain more than onesection*
, how about providing for an optional argument that allows the middle element (the letter) to be specified explicitly at the start of that section.
– barbara beeton
2 hours ago
@barbarabeeton Good idea. Done!
– Andrew
25 mins ago
nice, but on the (not unlikely) assumption that a document will contain more than one
section*
, how about providing for an optional argument that allows the middle element (the letter) to be specified explicitly at the start of that section.– barbara beeton
2 hours ago
nice, but on the (not unlikely) assumption that a document will contain more than one
section*
, how about providing for an optional argument that allows the middle element (the letter) to be specified explicitly at the start of that section.– barbara beeton
2 hours ago
@barbarabeeton Good idea. Done!
– Andrew
25 mins ago
@barbarabeeton Good idea. Done!
– Andrew
25 mins ago
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f463247%2ftheorem-numbering-in-starred-sections%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
i edited the tags to remove
amsmath
. theorems are (almost) entirely separate from the math component. i addedamsthm
since that is what you are using in your mwe.– barbara beeton
2 hours ago