I successfully used \newlistof{listofA}{A}{List of As} and \newlistentry{mycounter}{A}{0} to create a list of A, whose contents gets added using \addcontentsline{A}{mycounter}{\protect\numberline{\themycounter}...}. Now I want to have a list of B's that shares the counter mycounter. I have \newlistof{listofB}{B}{List of Bs}. \newlistentry{mycounter}{B}{0} fails with a few Command ... already defined. Without it, using \addcontentsline{B}{mycounter}{...}, both lists turn out empty. What am I doing wrong?

  • Can you, instead of providin a recipe with sie notes, just add a minimal working example, that we can copy/paste and compile and directly see the issue you see?
    – Johannes_B
    Jan 29 '17 at 15:29
  • I guess I should.
    – burnpanck
    Jan 29 '17 at 15:30
  • Because, the minimal non-working example does actually work! My bad. I'll delete in a few hours.
    – burnpanck
    Jan 29 '17 at 15:38

With the xassoccnt package it is possible to couple multiple counters, i.e. if one of the counters is stepped, to other ones are stepped too.

Declare a counters group with some 'arbitrary' name and assign the relevant counters to them.

Using the same counter is not possible since \newlistof expects a non-existing counter, say, foo and generates a bunch of commands out of the counter name.




\newcommand{\listoffooname}{List of foo environments}
\newcommand{\listoffoobarname}{List of foobar environments}



% Dummy usage of the counter and generating a 'ToC' entry
  \par\noindent\textbf{Foo \thefoo. #1}
  \addcontentsline{foo}{foo}{\protect\numberline{\thefoo} #1}\par%

  \par\noindent\textbf{Foobar \thefoobar. #1}
  \addcontentsline{foobar}{foobar}{\protect\numberline{\thefoobar} #1}\par%


\section{Where foo starts}

\begin{foo}{A nice foo}


\begin{foobar}{A nice foobar}


\begin{foo}{A nice foo again}


\begin{foo}{A nice foo again}


\begin{foobar}{A nice foobar again}


\section{Where foo ends}

\begin{foo}{Another nice foo too}


\begin{foobar}{Another nice foobar}



enter image description here

  • Another, 'quicker' method \let\c@foobar\c@foo
    – user31729
    Jan 29 '17 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.