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.










share|improve this question
























  • 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















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.










share|improve this question
























  • 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













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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago









barbara beeton

68.9k9155367




68.9k9155367










asked 4 hours ago









prt13463

424




424












  • 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
















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










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:



enter image description here



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*}





share|improve this answer























  • 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











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',
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
});


}
});














draft saved

draft discarded


















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

























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:



enter image description here



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*}





share|improve this answer























  • 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















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:



enter image description here



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*}





share|improve this answer























  • 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













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:



enter image description here



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*}





share|improve this answer














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:



enter image description here



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*}






share|improve this answer














share|improve this answer



share|improve this answer








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 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


















  • 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
















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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)