# Extracting information from multiple LaTeX (Beamer) documents

I have a number of slides prepared using LaTeX Beamer. They all belong to the same lecture series. Now, I would like to dynamically generate a Table of Content based on those multiple slides.

The input would look like a number XY of slides, e.g.

slides_XY.tex

\documentclass[aspectratio=169,14pt]{beamer}

\title{Lecture XY}

\begin{document}

\section{A section}
\begin{frame}[plain]{Hello}
\titlepage
\end{frame}

\begin{frame}[plain]{Bye}
\end{frame}

\end{document}


and then I would like to collect all title values from all files to form the top-level list, the sections within slides_XY.tex to become second-level lists within title and the frame titles to become third-level lists within sections.

e.g.

1. Lecture 01
1. A section
1. Hello
2. Bye
2. Lecture 02

etc.

If I try to use \input{}, I just get everything in the document AND I get multiple definitions of \title, among other problems.

I could do this with an external script, but I would like to keep this within LaTeX because the end goal would be to deploy those slides AND the overview with Overleaf.

• Beamer uses things like \@writefile{toc}{\beamer@sectionintoc {1}{A section}{1}{0}{1}} in the aux file instead of the usual \@writefile{toc}{\contentsline {section}{\numberline {1}A section}{1}\protected@file@percent } in the aux file. You might be able to access them directly, but using them will be a problem. – John Kormylo Apr 18 at 14:12