附录中的命名定义和表格

附录中的命名定义和表格

我有一个关于appendix环境的问题。请考虑以下示例:

\documentclass[10 pt,a4paper,oneside,openany, notitlepage]{article}
\usepackage{amsmath, amssymb, graphics}
\usepackage{mathtools}
\usepackage{amsthm}
\usepackage{amsfonts}
\marginparwidth 0pt
\oddsidemargin 0pt
\evensidemargin 0pt
\marginparsep 0pt
\linespread{1.5}
\topmargin 0pt
\textwidth 6.5in
\textheight 8.5 in
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{definition}{Definition}
\usepackage{hyperref}
\usepackage{bigints}
\usepackage{caption}
\usepackage{chngcntr}
\usepackage[multiple]{footmisc}
\usepackage{xr}
\numberwithin{equation}{section}


\begin{document}
\begin{appendix}
\counterwithin{theorem}{section}

\section{supplement 1}

\begin{equation}
2x=6
\end{equation}

\begin{definition}
blah blah
\end{definition}
\section{supplement 2}

\begin{table} [ht]
\caption{Descriptive statistics. All definitions are illustrated above.}
\centering
{\scriptsize
\begin{tabular}{|c|c|}
\hline  
2 & 2\\
3 & 3\\
\hline
\end{tabular}}
\label{statistics_appendix}
\end{table}


\end{appendix}
\end{document}

如何才能获得名为 Definition A.1 而不是 Definition 1 的定义以及名为 Table B.1 而不是 Table 1 的表?

答案1

只需使用

\counterwithin{definition}{section}
\counterwithin{table}{section}

就像已经做的那样theorem

\documentclass[10 pt,a4paper,oneside, notitlepage]{article}
\usepackage{amsmath, amssymb, graphics}
\usepackage{mathtools}
\usepackage{amsthm}
\usepackage{amsfonts}
%\marginparwidth 0pt
%\oddsidemargin 0pt
%\evensidemargin 0pt
%\marginparsep 0pt
%\linespread{1.5}
%\topmargin 0pt
%\textwidth 6.5in
%\textheight 8.5 in
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{definition}{Definition}
\usepackage{bigints}
\usepackage{caption}
\usepackage{chngcntr}
\usepackage[multiple]{footmisc}
\usepackage{xr}
\usepackage{hyperref}
\numberwithin{equation}{section}

\usepackage{xpatch}
\xapptocmd{\appendix}{%
  \counterwithin{theorem}{section}
  \counterwithin{definition}{section}
  \counterwithin{table}{section}
}{\typeout{Success}}{}



\begin{document}


\appendix

\section{supplement 1}

\begin{equation}
2x=6
\end{equation}

\begin{definition}
blah blah
\end{definition}
\section{supplement 2}

\begin{table} [ht]
\caption{Descriptive statistics. All definitions are illustrated above.}
\centering
{\scriptsize
\begin{tabular}{|c|c|}
\hline  
2 & 2\\
3 & 3\\
\hline
\end{tabular}}
\label{statistics_appendix}
\end{table}

\end{document}

在此处输入图片描述

相关内容