beamer add tag
JeT
**My question**

How can I restart the section counter on Toc based on `\lecture` ?

**Context**

SamCarter taught me how to create a `tableofcontent` in Beamer, based on `\lecture`. 

https://tex.stackexchange.com/questions/471060/lectures-toc-in-beamer

To restart the section counter after parts I use
`\makeatletter
\@addtoreset{section}{part}
\makeatother`

When I try this synthax

`\makeatletter
\@addtoreset{section}{lecture}
\makeatother`

no error but no apparent action on the section counters.


**Probably related,** 
(I ask cause it might deserve a new question)how can I get the menu on top to be based on the split by `\lecture` ? 

![LectureToc.png](/image?hash=bd5b90e7c8d6441a60d32c6f9248c896091ba061cd4eeca69fb1d651d0f60fe8)



MWE
```
\documentclass{beamer}
\usetheme{Copenhagen}

\makeatletter
\@addtoreset{section}{lecture}
\makeatother

\setbeamercolor{lecture in toc}{parent=structure}

\makeatletter
\long\def\beamer@lecture[#1]#2#3{%
  \beamer@savemode
  \mode<all>%
  \refstepcounter{lecture}%
  \def\beamer@currentlecturelabel{#3}%
  \@onelevel@sanitize\beamer@currentlecturelabel
  \def\beamer@lecturename{#2}%
  \def\beamer@shortlecturename{#1}%
  \ifx\beamer@onlylecture\@empty
  \else
    \expandafter\beamer@if@in@clist@TF\expandafter\beamer@onlylecture
      \expandafter{\beamer@currentlecturelabel}%
      {\beamer@inlecturetrue}%
      {\beamer@inlecturefalse}%
  \fi
  \beamer@atbeginlecture
  \beamer@resumemode
  \addtocontents{toc}{%
    \protect\usebeamercolor[fg]{lecture in toc}%
    \vfill%
    #2%
  }
}
\makeatother

\title{Some Title}

\begin{document}

\begin{frame}
%    \setcounter{secnumdepth}{-1}
%  \tableofcontents[hideallsubsections]
  \tableofcontents

\end{frame}

\lecture{Lecture1}{lec1}
\section{Section 1}
\subsection{Subsection 1a}
\frame{}
\subsection{Subsection 1b}
\frame{}
\subsection{Subsection 1c}
\frame{}

\section{Section 2}
\frame{}

\lecture{Lecture2}{lec2}
\section{Section 1}
\subsection{Subsection 1a}
\frame{}
\subsection{Subsection 1b}
\frame{}
\subsection{Subsection 1c}
\frame{}

\end{document}
```
Top Answer
samcarter
Similar to this [recent post on technique.fr](https://texnique.fr/osqa/questions/9233/reinitialisation-de-compteurs/9235) you can use `\AtBeginLecture{\beamer@tocsectionnumber=0}` to reset the toc section number at the start of a lecture. 

```
\documentclass{beamer}
\usetheme{Copenhagen}

\setbeamercolor{lecture in toc}{parent=structure}

\makeatletter
\AtBeginLecture{%
  \addtocontents{toc}{%
    \protect\usebeamercolor[fg]{lecture in toc}%
    \vfill%
    \beamer@lecturename%
  }
  \beamer@tocsectionnumber=0
}
\makeatother

\title{Some Title}

\begin{document}

\begin{frame}
  \tableofcontents
\end{frame}

\lecture{Lecture1}{lec1}
\section{Section 1}
\subsection{Subsection 1a}
\frame{}
\subsection{Subsection 1b}
\frame{}
\subsection{Subsection 1c}
\frame{}

\section{Section 2}
\frame{}

\lecture{Lecture2}{lec2}
\section{Section 1}
\subsection{Subsection 1a}
\frame{}
\subsection{Subsection 1b}
\frame{}
\subsection{Subsection 1c}
\frame{}

\end{document}
```

![Screen Shot 2020-09-22 at 23.53.55.png](/image?hash=fa76b393cbae7c5bc78b446e20065b25993774c99ff4b89b1b6c4157efbd9702)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.