图表连续编号更改不起作用

图表连续编号更改不起作用

我知道这个话题:连续编号,即按章节/节对图表、表格和其他文档元素进行编号我尝试使用给出的选项,但都不起作用。我正在使用memoir类。我做错了什么?

我试过:

\documentclass{memoir}

\usepackage{chngcntr}
\counterwithout{figure}{chapter}

\begin{document}
\chapter{A}
\begin{figure}
\centering
\caption{A figure}
\end{figure}

\end{document}

图仍为1.1。

于是,我试了一下,\counterwithout{figure}{chapter}因为memoir支持这个命令。图仍然是 1.1。

所以我尝试了:

\usepackage[figurewithin=none]{caption}

图仍为1.1。


@jon 这是我的“样式文件”,名为 folhadeestilos.txt:

% ---
% Pacotes
% ---
\usepackage[brazilian]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[none]{hyphenat}
\usepackage{tabularx}
\usepackage{graphicx}
\usepackage[authoryear,round]{natbib}

% ---
% Margens
% ---
\setlrmarginsandblock{3cm}{2cm}{*}
\setulmarginsandblock{3cm}{2cm}{*}
\setheaderspaces{*}{1cm}{*}

\checkandfixthelayout

% ---
% Fonte Arial
% ---
\usepackage[scaled]{uarial}
\renewcommand*\familydefault{\sfdefault}
%\usepackage{microtype}

% ---
% Customização da numeração de páginas e das seções
% ---
\renewcommand{\printtoctitle}[1]{%
    \centering\large\bfseries\MakeUppercase{#1}}
\renewcommand{\aftertoctitle}{%
\thispagestyle{empty}\afterchaptertitle}

\renewcommand{\printloftitle}[1]{%
    \centering\large\bfseries\MakeUppercase{#1}}
\renewcommand{\afterloftitle}{%
\thispagestyle{empty}\afterchaptertitle}

\renewcommand{\printlottitle}[1]{%
    \centering\large\bfseries\MakeUppercase{#1}}
\renewcommand{\afterlottitle}{%
\thispagestyle{empty}\afterchaptertitle}

\chapterstyle{tandh}
\aliaspagestyle{chapter}{simple}
\setlength\beforechapskip{-\baselineskip}

\renewcommand{\printchaptertitle}[1]{%
    \large\bfseries\MakeUppercase{#1}}
\renewcommand{\printchapternum}{%
    \large\bfseries \thechapter\space}

\setsecheadstyle{\large\bfseries}

\renewcommand{\bibname}{Referências Bibliográficas}
\AtBeginDocument{\renewcommand{\bibsection}{\chapter{\bibname}}}

% ---
% Legendas e numeração de figuras e tabelas
% ---
\usepackage[center,small,bf]{caption}

% ---
% Ambiente matemático em sans serif
% ---
\everymath{\mathsf{\xdef\mysf{\mathgroup\the\mathgroup\relax}}\mysf}

% ---
% Hyperref
% ---
\usepackage[hidelinks]{hyperref}

这是我简化的主文件:

\documentclass[a4paper,12pt,oneside]{memoir}
\input{folhadeestilos.tex}

\begin{document}

...

\pagestyle{simple}
\input{mem.tex}

\end{document}

其中 mem.tex 包含\begin{figure}环境。

答案1

这对我有用(经过修改,考虑到新的文件结构):

\documentclass[12pt,openany]{memoir}
\usepackage{filecontents}% <--- used to create the two other files 'on the fly' (it makes the example self-contained)

\begin{filecontents}{folhadeestilos.sty}
 \usepackage[brazilian]{babel}
 \usepackage[latin1]{inputenc}
 \usepackage[T1]{fontenc}
 \usepackage[none]{hyphenat}
\end{filecontents}

\begin{filecontents}{mem.tex}
 \begin{table}[h]
   \centering
   \begin{tabular}{ll}
     a & b \\
   \end{tabular}
   \caption{table one}
 \end{table}

 \begin{figure}[h]
   \centering
    \caption{caption one}
 \end{figure}
\end{filecontents}

\usepackage{folhadeestilos}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\begin{document}

\chapter{one}

\input{mem.tex}

\section{two}

\begin{table}[h]
  \centering
  \begin{tabular}{ll}
    a & b \\
  \end{tabular}
  \caption{table two}
\end{table}

\begin{figure}[h]
  \centering
    \caption{caption two}
\end{figure}

\chapter{three}

\begin{table}[h]
  \centering
  \begin{tabular}{ll}
    a & b \\
  \end{tabular}
  \caption{table three}
\end{table}

\begin{figure}[h]
  \centering
    \caption{caption three}
\end{figure}

\section{four}

\begin{table}[h]
  \centering
  \begin{tabular}{ll}
    a & b \\
  \end{tabular}
  \caption{table four}
\end{table}

\begin{figure}[h]
  \centering
    \caption{caption four}
\end{figure}

\end{document}

如果您正在使用memoir命令\<front|main|back>matter,您将需要更新一些定义才能\counterwithout按预期工作。

因此,在这种情况下,您可以在序言中添加以下内容(其中所有图表都位于“mainmatter”部分):

\makeatletter 
 \renewcommand\@memmain@floats{%
   \counterwithout{figure}{chapter} 
   \counterwithout{table}{chapter}}             
\makeatother

(例如,这可以在您的个人.sty文件中执行;但在这种情况下,您不需要这两个\makeat*命令。)

不太优雅的是,您可以简单地将\counter*命令移至声明之后\mainmatter

答案2

现在,memoir 3.7 手册对此进行了更好的解释。如上所述,\mainmatter重置编号。以下是手册中现在提到的解决方案:

\makeatletter
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\renewcommand\@memfront@floats{}
\renewcommand\@memmain@floats{}
\newcommand\@memback@floats{}
\makeatletter

这三个\...@floats宏分别由\frontmatter\mainmatter\backmatter和以各种方式重置发出。

相关内容