TransWikia.com

How to change section number to relabel theorems(newtcbtheorem 3.1 to 1.1) while preserving sections in progress bar in Beamer?

TeX - LaTeX Asked by CSA on December 7, 2020

Here is my MWE: I have a two sections(Review and Summary) before my First section (section 3) and Second sections (section 4). So Theorems in my First/Second sections get numbered Theorem 3.1 and Theorem 4.1 because they are really in the third/fourth sections. I would like to relabel sections so the First section is labelled section 1, the Second section is labelled section 2 and so forth so that theorems get labelled Theorem 1.1 instead of Theorem 3.1 in my First section and so forth, but without affecting the progress bar so that in the progress bar it is still shows that it is moving in the third/fourth sections when in these corresponding renumbered sections:i.e.
section 3 -> First section -> renumbered section 1 but moving in section 3 of progress bar
section 4 -> Second section -> renumbered section 2 but moving in section 4 of progress bar
I tried setcounter{section}{0}renewcommand{thesection} before the Summary section an it did not work.

MWE output

Review
Summary
First section
Theorem 3.1

Second Section
Theorem 4.1

Progress bar shows moving in Review, Summary then First then Second section (which is the third and fourth section); good

Wanted

Review
Summary
First section
Theorem 1.1

Second section
Theorem 2.1

Progress bar should be moving the same way as in MWE from Review to Summary to First and Second sections even after having renumbered the sections 3 and 4 (First and Second section) sections 1 and 2 to get proper theorem numbering

documentclass[slidetop, 11pt, leqno, french, english]{beamer}  
begin{filecontents}{Mybib.bib}
@article{au20,
     Author = {Author1},
     Journal = {journal},
     Pages = {56-80},
     Title = {Title},
     Volume = {2},
     Year = {2020}}
@article{au19,
     Author = {Author2},
     Journal = {journal},
     Pages = {20-40},
     Title = {Title},
     Volume = {10},
     Year = {2019}}
@article{au86,
     Author = {Author3},
     Journal = {journal},
     Pages = {23-56},
     Title = {Title},
     Volume = {15},
     Year = {1986}}
end{filecontents}

usepackage{multibib}
usepackage{natbib}
newcites{ra}{Review}

usepackage{babel}
usepackage{graphicx}
usepackage{amssymb}
usepackage{latexsym}
usepackage{amsmath}
usepackage{amsthm}
usepackage{pifont}
usepackage{multicol}
usepackage{xcolor}
usepackage{textpos}
usepackage{arydshln}  

usepackage{appendixnumberbeamer}
usepackage{apptools}
AtAppendix{setcounter{section}{0}renewcommand{thesection}{Alph{section}}}

usepackage{tcolorbox}
tcbuselibrary{theorems}

usepackage{nameref}
usepackage{hyperref}

newtcbtheorem[number within=section]{lem}{Lemma}%
{colback=white,colframe=bluegreen,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{thm}{Theorem}%
{colback=white,colframe=bluegreen,fonttitle=bfseries}{th}
newtcbtheorem[number within=section]{cor}{Corollary}%
{colback=white,colframe=bluegreen,fonttitle=bfseries}{th}

usetheme{Dresden}
useoutertheme{miniframes}

definecolor{bluegreen}{rgb}{0.0,0.57,0.5}
usecolortheme[named=bluegreen]{structure}

bibliographystyle{apalike}
bibliographystylera{apalike}
renewcommandbibfont{scriptsize}
setbeamertemplate{frametitle continuation}[from second]
setbeamercolor*{bibliography entry title}{fg=black}
setbeamercolor*{bibliography entry author}{fg=black}
setbeamercolor*{bibliography entry location}{fg=black}
setbeamercolor*{bibliography entry note}{fg=black}
setbeamertemplate{bibliography item}{}

title{Title}
subtitle{Subtitle}
author[Author]{Author}

defvs{vspace*{0.3cm}}

begin{document}  

begin{frame}
titlepage
end{frame}

begin{frame}{Review}
bibliographyra{Mybib}
vs
Some review material in order:
vs
Some topics first: citera{au19} 
Some more topics second: citera{au20} 
end{frame}

section{Summary}
begin{frame}
tableofcontents
end{frame}

section{First section}
begin{frame}
begin{thm}{}{}
an important result
end{thm}
Proof: uses the nameref{th:stat} in ref{th:stat}
end{frame}

section{Second section}
begin{frame}
begin{thm}{}{}
An even more important result.
end{thm}
Proof: Also uses nameref{th:stat} in ref{th:stat} and nameref{th:stat2} in ref{th:stat2} and cite{au86}
end{frame}
begin{frame}[t,allowframebreaks]{Bibliography}
bibliography{Mybib}
end{frame}

appendix
section{Appendix A}
begin{frame}
begin{thm}{Stat lemma}{stat}
Statement of the lemma here
end{thm}
end{frame}
section{Appendix B}
begin{frame}
begin{thm}{Another Stat lemma}{stat2}
Statement of the lemma here
end{thm}
end{frame}  

end{document}

One Answer

Here is a partial answer. Any further help would be appreciated.
After looking into the tcolorbox manual I figured I could create a new section counter which I called newsect and use it instead of section in the theorem command

newcounter{newsect}[enumi]
AtAppendix{setcounter{newsect}{0}renewcommand{thenewsect}{Alph{section}}} % needed for appendix  
% with another command before the appendix see full code  
newtcbtheorem[number within=newsect]{lem}{Lemma}%
{colback=white,colframe=bluegreen,fonttitle=bfseries}{th}
newtcbtheorem[number within=newsect]{thm}{Theorem}%
{colback=white,colframe=bluegreen,fonttitle=bfseries}{th}
newtcbtheorem[number within=newsect]{cor}{Corollary}%
{colback=white,colframe=bluegreen,fonttitle=bfseries}{th}  

and then set the counter newsect before each section
the tcolorbox manual says: p.113

/tcb/new/number within=〈counter〉(no default, initially unset)
The automatic counter is set to zero, if〈counter〉is increased. Additionally, during output,the value of〈counter〉is prepended to the value of the automatic counter.To prepend the automatic counter with the chapter number and to reset it with every new chapter, use:number within=chapter

so I thought when my counter newsect is incremented by a manual increment before a section, that the automatic numbering would get reset, i.e. the number in number within=newsect would reset, it appears not to...I figure it has to do with the fact that my newsect counter is really not like a section or chapter so I must be missing a lot of coding to get it to work like that.

So I managed to get the numbering of the sections renumbered while preserving the corresponding progress in the sections in the progress bar since it is only in the theorem/lemma/corollary defs it does not affect the progress bar sections, so that works well, but now my counter number does not get reset.

MWE gives

Review
Summary
First section
Theorem 1.1

Theorem 1.2

Second Section
Theorem 2.3

Theorem 2.4

Appendix A

Theorem A.5

Appendix B

Theorem B.6

while preserving the progress bar sections

Wanted

Review
Summary
First section
Theorem 1.1

Theorem 1.2

Second Section
Theorem 2.1

Theorem 2.2

Appendix A

Theorem A.1

Appendix B

Theorem B.1

while preserving the progress bar sections

I tried a suggestion I read on a post on how to manipulate number counters in tcolorbox and tcbtheorem command but I could not get it to work, specifically in the call to the theorem add a code= command as in:

begin{thm}[code={setcounter{tcbcounter}{1}}]{}{} % 
An even more important result.
end{thm}

I would need to know how to reset the number in number within=newsect when the counter newsect gets increased manually or otherwise to make the reseting of number work, that is while using a new counter in the within= part!

Here is the full code of the new MWE

documentclass[slidetop, 11pt, leqno, french, english]{beamer}
begin{filecontents}{Mybib.bib}
@article{au20,
     Author = {Author1},
     Journal = {journal},
     Pages = {56-80},
     Title = {Title},
     Volume = {2},
     Year = {2020}}
@article{au19,
     Author = {Author2},
     Journal = {journal},
     Pages = {20-40},
     Title = {Title},
     Volume = {10},
     Year = {2019}}
@article{au86,
     Author = {Author3},
     Journal = {journal},
     Pages = {23-56},
     Title = {Title},
     Volume = {15},
     Year = {1986}}
end{filecontents}

usepackage{multibib}
usepackage{natbib}
newcites{ra}{Review}

usepackage{babel}
usepackage{graphicx}
usepackage{amssymb}
usepackage{latexsym}
usepackage{amsmath}
usepackage{amsthm}
usepackage{pifont}
usepackage{multicol}
usepackage{xcolor}
usepackage{textpos}
usepackage{arydshln}
usepackage{appendixnumberbeamer}

usepackage{apptools}
%AtAppendix{setcounter{section}{0}renewcommand{thesection}{Alph{section}}}

usepackage{tcolorbox}
tcbuselibrary{theorems}

usepackage{nameref}
usepackage{hyperref}

newcounter{newsect}[enumi]
AtAppendix{setcounter{newsect}{0}renewcommand{thenewsect}{Alph{section}}}
newtcbtheorem[number within=newsect]{lem}{Lemma}%
{colback=white,colframe=bluegreen,fonttitle=bfseries}{th}
newtcbtheorem[number within=newsect]{thm}{Theorem}%
{colback=white,colframe=bluegreen,fonttitle=bfseries}{th}
newtcbtheorem[number within=newsect]{cor}{Corollary}%
{colback=white,colframe=bluegreen,fonttitle=bfseries}{th}

usetheme{Dresden}
useoutertheme{miniframes}

definecolor{bluegreen}{rgb}{0.0,0.57,0.5}
usecolortheme[named=bluegreen]{structure}

bibliographystyle{apalike}
bibliographystylera{apalike}
renewcommandbibfont{scriptsize}
setbeamertemplate{frametitle continuation}[from second]
setbeamercolor*{bibliography entry title}{fg=black}
setbeamercolor*{bibliography entry author}{fg=black}
setbeamercolor*{bibliography entry location}{fg=black}
setbeamercolor*{bibliography entry note}{fg=black}
setbeamertemplate{bibliography item}{}

title{Title}
subtitle{Subtitle}
author[Author]{Author}

defvs{vspace*{0.3cm}}

begin{document}

begin{frame}
titlepage
end{frame}

begin{frame}
bibliographyra{Mybib}
vs
Some review material in order:
vs
Some topics first: citera{au19} 
Some more topics second: citera{au20} 
end{frame}

section{Summary}
begin{frame}
tableofcontents
end{frame}

setcounter{newsect}{1}
section{First section}
begin{frame}
begin{thm}{}{}
an important result
end{thm}
Proof: uses the nameref{th:stat} in ref{th:stat}
begin{thm}{}{}
a second important result
end{thm}
Proof: uses the nameref{th:stat} in ref{th:stat}
end{frame}

% setcounter{newsect}{2} does not work either
addtocounter{newsect}{1}
section{Second section}
begin{frame}
begin{thm}[code={setcounter{tcbcounter}{10}}]{}{} % from a suggestion this might work but it does not
An even more important result.
end{thm}
Proof: Also uses nameref{th:stat} in ref{th:stat} and nameref{th:stat2} in ref{th:stat2} and cite{au86}
begin{thm}{}{}
A second even more important result.
end{thm}
end{frame}

begin{frame}[t,allowframebreaks]{Bibliography}
bibliography{Mybib}
end{frame}

AtAppendix{setcounter{section}{0}renewcommand{thesection}{Alph{section}}}
appendix
section{Appendix A}
begin{frame}
begin{thm}{Stat lemma}{stat}
Statement of the lemma here
end{thm}
end{frame}
section{Appendix B}
begin{frame}
begin{thm}{Another Stat lemma}{stat2}
Statement of the lemma here
end{thm}
end{frame}

end{document}

Answered by CSA on December 7, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP