班级回忆录错误:列表不是计数器

班级回忆录错误:列表不是计数器

我正在尝试使用\counterwithout{listing}{chapter}

  1. Chngcntr:\counterwithout 不起作用
  2. 列表编号方式与图表和表格相同

但回忆录却不断抱怨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}

回顧代碼:

\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}}}}

答案1

正如所说@Ulrike Fischer, 代替listing

计数器的名称是lstlisting

相关内容