0

I'm creating a LaTeX document (on Overleaf) filled with mathematical theorems and proofs. To quickly overview which theorems have been proven, I need a custom table of contents (TOC) that organizes theorems under specific headings at the beginning of the document. I've defined a command:

\newRegister{Content}{Heading}

to mark theorem statements. Content is a brief description or name of the theorem, and

Heading is the category. The TOC should list these under their Heading, with clickable

Content leading to their location in the document.

Example entries:

\newRegister{In1}{Headline1}
\newRegister{In2}{Headline1}
\newRegister{In3}{Headline3}

The TOC should automatically organize and display them as:

Headline1
    In1
    In2
Headline3
    In3

How can I implement a dynamic, clickable TOC based on \newRegister entries?

Thanks for any guidance!

I can manually make the TOC with following code. But is their a more general approach for command \printRegister whitch allows me to insert any kind of headline and formula (e.g. \newRegister{in4}{Headline4} in the document tag) without any more adjustment of the command \printregister?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}

\newcommand{\newRegister}[2]{
    \noindent\hyperlink{#1}{#1}\\
    \hypertarget{#1}{}
}

\newcommand{\printRegister}{
    \section*{Inhaltsverzeichnis}
    \noindent\textbf{Headline1}\\
    \newRegister{In1}{Headline1}
    \newRegister{In2}{Headline1}
    \noindent\textbf{Headline3}\\
    \newRegister{In3}{Headline3}
}

\begin{document}
    
    \printRegister
    
    \section*{Theoreme}
    
    \subsection*{Headline1}
    \newRegister{In1}{Headline1}
    some content
    
    \newRegister{In2}{Headline1}
    some more content
    
    \subsection*{Headline3}
    \newRegister{In3}{Headline3}
    content
    
\end{document}
6
  • Have you tried the \listoftheorems from thmtools (with two different theorem environment for proven and not which share the same names and counters)? Commented Mar 27 at 15:57
  • Some possibilities in that vein: tex.stackexchange.com/q/74857/107497
    – Teepeemm
    Commented Mar 27 at 15:59
  • Can you explain why the suggested solutions don't do what you want? Why aren't you using any of the existing packages for managing theorems?
    – cfr
    Commented Mar 28 at 6:18
  • I doubt that the code provided in the example works: \newRegister takes two arguments but processes only one of them. And you get hypertargets/anchors with same name several times.And Overleaf is just some web-interface for using some TeX engine from some TeX Live distribution. Relevant would be information which ones you use/you selected in in the Overleaf-Web-Interface for having your .tex-files compiled. Commented Apr 9 at 1:06
  • If you use \newtheorem for defining theorem-like environments, you can use the package datatool for adding data, e.g., the anchor stored in \@currentHref, to a database which at the end of the LaTeX-run is written to file so that with the next LaTeX run it can be read for sorting entries and printing entries wherever you like. Thus actually you need two databases: One which is read at the beginning and contains data created in the previous LaTeX-run for printing. One which is created and written to during the current LaTeX-run so that its data is available in the next LaTeX-run. Commented Apr 9 at 1:12

0

You must log in to answer this question.

Browse other questions tagged .