I am trying to use \counterwithout{listing}{chapter}
But memoir keeps complaining Class memoir Error: listing is not a counter
\documentclass[english,12pt,a4paper,twoside]{memoir}
\usepackage{listings}
\AtBeginDocument{\counterwithout{listing}{chapter}}
\begin{document} % test5.tex:5: Class memoir Error: listing is not a counter.
\chapter{Hi}
\begin{lstlisting}[caption=Code,label=acode]
Code
\end{lstlisting}
Something...
\end{document}
Memoir code:
\newcommand{\@ifbothcntrs}[3]{%
\@ifundefined{c@#1}{% counter undefined
\@memerror{#1 is not a counter}{\@eha}}%
{% else counter is defined
\@ifundefined{c@#2}{% within undefined
\@memerror{#2 is not a counter}{\@eha}}%
{% else both counter and within are defined
#3}}}
\newcommand{\counterwithin}{\@ifstar{\@csinstar}{\@csin}}
\newcommand{\@csinstar}[2]{%
\@ifbothcntrs{#1}{#2}{\@addtoreset{#1}{#2}}}
\newcommand{\@csin}[2]{%
\@ifbothcntrs{#1}{#2}{\@addtoreset{#1}{#2}%
\@namedef{the#1}{\@nameuse{the#2}.\arabic{#1}}}}
\newcommand{\counterwithout}{\@ifstar{\@csoutstar}{\@csout}}
\newcommand{\@csoutstar}[2]{%
\@ifbothcntrs{#1}{#2}{\@removefromreset{#1}{#2}}}
\newcommand{\@csout}[2]{%
\@ifbothcntrs{#1}{#2}{\@removefromreset{#1}{#2}%
\@namedef{the#1}{\arabic{#1}}}}
minted
(which defines the counterlisting
) instead of including the packagelistings
(which defines the counterlstlisting
. – user Aug 2 '20 at 18:47