Advanced Theorems List from ntheorem Documentation throws errors

I have defined my theorems as follows

\documentclass[a4paper,twoside]{article}

\usepackage{amsmath,amsfonts,mathtools,framed}
\usepackage{enumitem} % einfacher Nummerierung ver√§ndern
\usepackage{listofitems} % für Farben für Kapitel

%%%%%%%%%%%%%%%%%%Theoreme%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[thmmarks,framed,thref]{ntheorem} % [thmmarks] guarantees endmarks

%theorem
\usepackage{tcolorbox}
\tcbuselibrary{theorems}
\newtcbtheorem[number within=subsection]{thm}{Satz}
{{colback=\mycolors[\thesection]!5},
{colframe=\mycolors[\thesection]!95!black},
fonttitle=\scshape\bfseries,
before skip=15pt plus 2pt,after skip=15pt plus 2pt}{th}

\setsepchar{,}

\newcounter{counter}
\numberwithin{counter}{subsection}

% defn
\theoremstyle{break}
\theoremprework{\medbreak}
\theorempostwork{\medbreak}
\theorembodyfont{\normalfont}
\theoremindent=5mm
\def\theoremframecommand{\colorbox{\mycolors[\thesection]!10}}

%lemma
\theoremstyle{break}
\theoremprework{%
\def\FrameCommand{
{\color{\mycolors[\thesection]}{\hspace{-8pt}\vrule width 2pt     \hspace{6pt}}}}
\medbreak}
\theorempostwork{\medbreak}
\theorembodyfont{\itshape}
\theoremindent0.5cm
\newframedtheorem{lemma}[counter]{Lemma}

\definecolor{amaranth}{HTML}{a82337}
\definecolor{orange}{HTML}{BF7F00}
\definecolor{blue}{HTML}{016FB9}
\definecolor{purple}{HTML}{603C96}

\newtheoremlisttype{tab}%
{\begin{tabular*}{\linewidth}{@{}lrl@{\extracolsep{\fill}}r@{}}}%
{##1&##2&##3&##4\\}%
{\end{tabular*}}
\begin{document}
\section{first section}
\begin{lemma}[first lemma]
This is a lemma
\end{lemma}

oh, another lemma!

\begin{lemma}[second lemma]
This is a lemma, also.
\end{lemma}

oh, another lemma!

\begin{lemma}[third lemma]
This is a lemma, also.
\end{lemma}

oh, another lemma!

\begin{lemma}[fourth lemma]
This is a lemma, also.
\end{lemma}

\begin{lemma}[another lemma]
This is a lemma, also.
\end{lemma}

\begin{lemma}[another lemma]
This is a lemma, also.
\end{lemma}
\begin{lemma}[another lemma]
This is a lemma, also.
\end{lemma}
\begin{lemma}[another lemma]
This is a lemma, also.
\end{lemma}
\begin{lemma}[another lemma]
This is a lemma, also.
\end{lemma}
\section{Alle wichtigen Definitionen und Lemmata}
\theoremlisttype{tab}
\listtheorems{defn,lemma}
\end{document}


Now I want to use the following extension from the ntheorem documentation, but counters pop up again :/ Bonus: How can I make a list of all theorems and lemmas?

• Can you specify your question? Which extension of ntheorem? What is the desired result? What is wrong with the counters? You have already a list of all lemmata that are used in your example code. – dexteritas Feb 3 at 13:03
• The extension is the \newtheorentype. It come directly from the documentation of ntheorem and the desired result is the result from the documentation. – Viktor Glombik Feb 3 at 13:57
• Do you mean \newtheoremlisttype? There are multiple examples in the documentation. So please be more specific where someone should find the desired result. Give a page number or describe the result directly in the question. – dexteritas Feb 3 at 14:11
• Yes, I do. The example is found on the bottom of page 26 and the result on page 27, I copied the code from the documentation as last thing in my preamble. – Viktor Glombik Feb 3 at 15:02

• removed: \newcounter{counter} and \numberwithin{counter}{subsection}
• added: \theoremnumbering{arabic} or \theoremnumbering{greek} (see page 17 of the ntheorem documentation)
• changed: \newframedtheorem{lemma}{Lemma}[subsection] to use subsection number + theoremnumbering
• added: new columntype L fot tabular, so long titles get a linebreak
• added: defn environments for testing the result
• note: use UTF8 coding as file encoding to preserve german umlauts. (see line 4)

Code:

\documentclass[a4paper,twoside]{article}

\usepackage{amsmath,amsfonts,mathtools,framed}
\usepackage{enumitem} % einfacher Nummerierung verändern
\usepackage{listofitems} % für Farben für Kapitel

%%%%%%%%%%%%%%%%%%Theoreme%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[thmmarks,framed,thref]{ntheorem} % [thmmarks] guarantees endmarks

%theorem
\usepackage{tcolorbox}
\tcbuselibrary{theorems}
\newtcbtheorem[number within=subsection]{thm}{Satz}
{{colback=\mycolors[\thesection]!5},
{colframe=\mycolors[\thesection]!95!black},
fonttitle=\scshape\bfseries,
before skip=15pt plus 2pt,after skip=15pt plus 2pt}{th}

\setsepchar{,}

% defn
\theoremstyle{break}
\theoremprework{\medbreak}
\theorempostwork{\medbreak}
\theorembodyfont{\normalfont}
\theoremindent=5mm
\def\theoremframecommand{\colorbox{\mycolors[\thesection]!10}}
\theoremnumbering{arabic} % <- NEW for arabic counter

%lemma
\theoremstyle{break}
\theoremprework{%
\def\FrameCommand{
{\color{\mycolors[\thesection]}{\hspace{-8pt}\vrule width 2pt     \hspace{6pt}}}}
\medbreak}
\theorempostwork{\medbreak}
\theorembodyfont{\itshape}
\theoremindent0.5cm
\theoremnumbering{greek} % <- NEW for greek counter
\newframedtheorem{lemma}{Lemma}[subsection] % subsection + greek

\definecolor{amaranth}{HTML}{a82337}
\definecolor{orange}{HTML}{BF7F00}
\definecolor{blue}{HTML}{016FB9}
\definecolor{purple}{HTML}{603C96}

\usepackage{tabularx}

\newtheoremlisttype{tab}%
{\begin{tabular*}{\linewidth}{@{}lrL{85mm}@{\extracolsep{\fill}}r@{}}}%
{##1&##2&##3&##4\\}%
{\end{tabular*}}

\begin{document}
\section{first section}

\subsection{first subsection}

\begin{lemma}[first lemma]
This is a lemma
\end{lemma}

\begin{lemma}[second lemma with a very long title to get a linebreak in tabular]
This is a lemma, also.
\end{lemma}

\begin{defn}[first theorem]
This is a theorem, also.
\end{defn}

\begin{lemma}[third lemma]
This is a lemma, also.
\end{lemma}

\begin{lemma}[fourth lemma]
This is a lemma, also.
\end{lemma}

\begin{defn}[second theorem]
This is a theorem.
\end{defn}

\begin{lemma}[fifth lemma]
This is a lemma, also.
\end{lemma}

\section{Alle wichtigen Definitionen und Lemmata}
\theoremlisttype{tab}
\listtheorems{defn,lemma}

\end{document}


Result:

• How can I modify this, so that for longer titles, this doesn't run over the edges? – Viktor Glombik Feb 3 at 22:53
• Also, when copying your code into an overleaf document, it throws an error, do you know why? – Viktor Glombik Feb 3 at 22:54
• Also, I changed the definition of the definition header font to \theoremheaderfont{\kern-5mm\bfseries\scshape} and removed it in the environment definition: \newshadedtheorem{defn}{Definition}[subsection], so that in this listing, the font of "Definition" is a normal one, like for the lemma. – Viktor Glombik Feb 3 at 23:02
• Also, I wanted to use: \usepackage[bookmarks=true,colorlinks=true,linkcolor=black]{hyperref} and even though I use \usepackage[thmmarks,framed,thref,hyperref]{ntheorem}, it still looks like this: lemma.1.1.1 Lemma & 1.1.\beta & second lemma. – Viktor Glombik Feb 3 at 23:19
• I changed the code, so you get a linebreak in the tabular for long titles. I don't know why overleaf should throw an error. About hyperref look at section 3.4 of the documentation and maybe ask a new question for that one. – dexteritas Feb 4 at 8:48