chngcntr 包适用于第一章,但不适用于本书的其他章节

chngcntr 包适用于第一章,但不适用于本书的其他章节

包装:

\usepackage{chngcntr} 
\counterwithin*{chapter}{part}
\renewcommand{\restoreapp}{}

适用于我的论文的第一章,但在其他两章中,计数从每个部分开始,我不知道为什么它不适用于接下来的章节。

\documentclass[12pt,a4paper,oneside]{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\rhead{\thepage}
\lhead{}
\renewcommand{\headrulewidth}{0pt}

\usepackage{fix-cm}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{amsmath}
\numberwithin{table}{chapter}
\usepackage{marvosym}

\usepackage[style=authoryear,natbib=true]{biblatex}
\usepackage{appendix}
\usepackage{chngcntr}
\counterwithin*{chapter}{part} %To reset chapter counter for every part
\renewcommand{\restoreapp}{}
\AtBeginEnvironment{subappendices}{%
\chapter*{Appendix}
\addcontentsline{toc}{chapter}{Appendices}
\counterwithin{figure}{section}
\counterwithin{table}{section}
}
%\usepackage[toc,page]{appendix}
\usepackage{hyperref}
\hypersetup{
     colorlinks   = true, 
     citecolor    = blue
}
% \usepackage{hypertex}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\addbibresource{inf.bib}
\addbibresource{aid.bib}
\addbibresource{csr.bib}
\usepackage{csquotes}
\usepackage{array}
\usepackage{longtable}
\usepackage{rotating}
\usepackage{booktabs}
\usepackage{makeidx} 
\usepackage{booktabs,caption,fixltx2e}
\usepackage[flushleft]{threeparttable}
\usepackage{bbm}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{caption}
\usepackage{float}
\floatstyle{plaintop}
\restylefloat{table}
\usepackage{multirow}
\usepackage{setspace}
\usepackage{rotfloat}
\usepackage{subcaption}
\usepackage{adjustbox} 
\usepackage{listings}
\usepackage{alltt}

\doublespacing

\restylefloat{figure}
\restylefloat{table}
\usepackage{mathtools}

\allowdisplaybreaks
\usepackage[lmargin=3.20cm,rmargin=3.0cm,tmargin=3cm,bmargin=3cm]{geometry}

% Set the beginning of a LaTeX document
\begin{document}

\setstretch{1.3}
\begingroup
\hypersetup{linkcolor=black}
\tableofcontents
\endgroup

\newpage
\mainmatter
\chapter{Ilkfo}
\label{Chapter 1} 

\begin{doublespace}
\section{Introduction}
Text....

\section{Literature review}
\subparagraph{Background...}

This section.....

%%%%%%
%Table 1
\begin{table} [htbp]
\centering
\caption{\label{tab1}
\textbf{Summar...}}
\begin{adjustbox}{max width=\textwidth}
\begin{threeparttable}
\begin{tabular}{l c c c c c}\hline 
\multicolumn{1}{c}{\textbf{Variable}} & \textbf{Mean}  & \textbf{Std. Dev.} & \textbf{Min.} &  \textbf{Max.} & \textbf{Obs.}\\ \hline  
\cline{1-6}
\multicolumn{6}{l}   {Panel A: } \\ \hline
Age &  &  &  &  & \\ \hline 
\multicolumn{6}{l}     {Panel B: } \\ \hline 
Age  &  &  &  &  & \\ \hline
\multicolumn{6}{l}     {Panel C: } \\ \hline 
Age &  &  &  &  & \\
\cline{1-6}
\end{tabular} 
\end{threeparttable}
\end{adjustbox}
\end{table}
%%%%%%

\section{Results}
\subsection{... results}
%%%%%%%%%%%%%%%%%%%
%Table 5: Main regression results

\begin{table} [htbp]
\centering
\caption{\label{general}
\textbf{Ma...}}
\begin{adjustbox}{max width=\textwidth}
\begin{threeparttable}
\begin{tabular}{lccccccc} \toprule
\multicolumn{8}{l}{ \emph{Infor}} \\ \hline  
& \multicolumn{3}{c}{Full sample} & \multicolumn{2}{c}{txt} & \multicolumn{2}{c}{text} \\
 & (1) & (2) & (3) & (4) & (5) & (6) & (7) \\  
  \midrule
 & & & & & & & \\
textx & *** &  &  & ** &  & - &  \\
\bottomrule
\end{tabular} 
\begin{tablenotes} \footnotesize \item Notes: text 
\end{tablenotes}
\end{threeparttable}
\end{adjustbox}
\end{table}
%%%%%%%%%%%%%%%%%%%

\end{doublespace}
\setstretch{1.3}
\newpage
\begin{subappendices} 
\section{Quarterly...}

\begin{table} [htbp]
\centering
\caption{\label{quarterlytransitions}
\textbf{text}}
\begin{adjustbox}{max width=\textwidth}
\begin{threeparttable}
\begin{tabular}{l c c }\hline 
\textbf{Change} & \textbf{$Formal_{t}$}  & \textbf{$Informal_{t}$} \\ \hline  
\cline{1-3}
\multicolumn{3}{l} {Panel A: } \\ \hline
$Informal_{t-1}$ & \% & \% \\  \hline   
\cline{1-3} 
\end{tabular}
\end{threeparttable}
\end{adjustbox}
\end{table}

\end{subappendices}

\backmatter
\pagebreak

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\pagebreak
\mainmatter
\chapter{Latin American...}
\label{Chapter 2} 

\begin{doublespace}
\section{Introduction}

\begin{table} [htbp]
\caption{\label{sumstatisticsaid}
\textbf{Summary }}
\begin{adjustbox}{max width=\textwidth}
\begin{threeparttable}
\centering
\begin{tabular}{l c c  c c }\hline
 & \multicolumn{2}{c}{\underline{\textbf{ World}}} &  \multicolumn{2}{c}{\underline{\textbf{Latin }}} \\
\multicolumn{1}{c}{Variable} & Mean  & Obs. & Mean & Obs.\\ 
 \hline
 &&&& \\
Ln per capita Income (US\$ constant) &    &  &    & \\ \hline
\end{tabular}
\begin{tablenotes} \footnotesize \item Sta
\end{tablenotes}
\end{threeparttable}
\end{adjustbox}
\end{table}

\section{Methodology}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% Table 1. MAIN SPECIFICATION %%%%%%%%%%%%%%%
\begin{table} [htbp]
\caption{\label{mainaid}
\textbf{Aid }}
\begin{adjustbox}{max width=\textwidth}
\begin{threeparttable}
\centering
\begin{tabular}{lcccc} \hline
 &\multicolumn{2}{c}{$ Aid$}  & \multicolumn{2}{c}{$d)$}  \\
 & (1) & (2) & (3) & (4) \\
 \hline
 &&&& \\
 &  &  &  &  \\
\bottomrule
\end{tabular}
\begin{tablenotes} \footnotesize \item ade. 
\item Notes: el. 
\end{tablenotes}
\end{threeparttable}
\end{adjustbox}
\end{table}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{doublespace}
\backmatter
\end{document}

目录如下所示:
1 第 1 章
1.1 简介....................................................................................................................................................................................................................
1.2 文献综述.................................................................................................................................................................................................................... 1.3
方法论.................................................................................................................................................................................................................... 1.3.1 概念.................................................................................................................................................................................... 12 1.3.2 实证.................................................................................................................................................................................... 1.3.1 概念....................................................................................................................................................................
12 1.3.2 实证....................................................................................................................................................................................
16
1.4 数据 .
... ​ ​



2 第 2 章
2.1 简介.....................................................................................................................................................................................
2.2 文献综述.................................................................................................................................................................... 2.3
数据....................................................................................................................................................................................
2.4 方法论.................................................................................................................................................................... 2.4 。 。
目录示例

答案1

我建议不要使用该appendix包(以便更好地控制发生的事情;否则您必须再次撤消您不喜欢的事情)。此外,\mainmatter只使用一次,否则它将再次重置页面计数器。如果您喜欢第二个的特定副作用\mainmatter,让我们明确实现它。

下面是一个示例文档,似乎可以生成您想要的内容。如果缺少任何内容,请告诉我。复制环境的定义appendices,删除\numberwithin{table}{chapter}(这是默认设置),删除\usepackage{appendix},删除\counterwithin*{chapter}{part}(您没有\parts),删除\renewcommand{\restoreapp}{},然后删除所有\AtBeginEnvironment{subappendices}内容。

附注:除特殊情况外,包hyperref应最后加载。此外,您加载了几个包两次(booktabscaption),但我不确定您真的需要adjustboxfloat以及其他几个包。您还有一个重复的\restylefloat{table}。您在序言中声明\doublespacing,但在文档的后面设置\setstretch{1.3}。通常,最好不要在没有充分理由的情况下从不同的文档和网页收集序言。

\documentclass{book}

\usepackage{chngcntr}
\newenvironment{appendices}%
  {\chapter*{Appendices}%
   \addcontentsline{toc}{chapter}{Appendices}%
   \setcounter{section}{0}%
   \def\thesection{\thechapter.\Alph{section}}%
   \counterwithin{figure}{section}%
   \counterwithin{table}{section}%
  }%
  {\counterwithout{figure}{section}%
   \counterwithout{table}{section}%
  }

\usepackage{lipsum}
\newcommand\somecontents
  {\lipsum[1]
   \begin{table}
     \centering
     \begin{tabular}{cc}
       a & b \\
       c & d
     \end{tabular}
     \caption{Some caption}
     \label{tab:\thetable}
   \end{table}
   \lipsum[2]
  }

\begin{document}
\frontmatter
\tableofcontents
\mainmatter

\chapter{Informality and Taxes in Mexico}
\section{Introduction}
\somecontents
\section{Literature review}
\somecontents
\section{Methodology}
\somecontents
\subsection{Conceptual framework and threats to identification}
\somecontents
\subsection{Empirical stratecy and specification}
\somecontents

\begin{appendices}
\section{Quaterly transitions between formality and informality}
\somecontents
\somecontents
\section{Formulas to calculate average tax rates}
\somecontents
\somecontents
\section{Narrative discussion of changes in tax rates}
\somecontents
\somecontents
\end{appendices}

\chapter{Latin American Aid Patterns: Democratic Political Regimes and US domestic Politics}
\section{Introduction}
\somecontents
\section{Literature review}
\somecontents
\section{Data}
\somecontents
\section{Methodology}
\somecontents
\end{document}

在此处输入图片描述

相关内容