我有一篇毕业论文,共三章,每章正文和附录后都有表格,每个附录也有表格,格式如下:
\documentclass[12pt,a4paper,twoside]{report}
\begin{document}
\include{chapter1}
\include{chapter2}
\include{chapter3}
\end{document}
以下是可重现的示例:
\documentclass[12pt,a4paper,twoside]{report}
\usepackage[top=2.54 cm, bottom=2.54 cm, left=2.54 cm, right=2.54 cm]{geometry}
\usepackage[hidelinks]{hyperref} % put before apacite
\usepackage[titletoc,title]{appendix}
\usepackage{tabularx}
\usepackage{blindtext}
\begin{document}
% chapter 1
\chapter{chapter1}\label{chp:This is chapter1}
\section{Introduction}
This paper examines
\section{Results}
\par Table \ref{tab:tab1} also indicates. But Appendix Table \ref{tab:apptab1}
\par Table \ref{tab:tab2} also indicates But Appendix Table \ref{tab:apptab2}
\section{\label{sec_conc} Conclusion}
% Tables
\begin{table}[!h]
\centering
\caption{\textbf{table 1}}
\begin{tabular}{rrrrr}
\hline
& \multicolumn{2}{c}{\textbf{1989}} & \multicolumn{2}{c}{\textbf{1992}} \\
\hline
& income1 & expenses1 & income2 & expenses2 \\
\hline
\end{tabular}%
\label{tab:tab1}%
\end{table}%
\begin{table}[!h]
\centering
\caption{\textbf{table 1}}
\begin{tabular}{rrrrr}
\hline
& \multicolumn{2}{c}{\textbf{1989}} & \multicolumn{2}{c}{\textbf{1992}} \\
\hline
& income1 & expenses1 & income2 & expenses2 \\
\hline
\end{tabular}%
\label{tab:tab2}%
\end{table}%
%Appendix
\clearpage
\newpage
\section*{Appendix A}
%\begin{appendices}
% Appendix 1A
\begin{subappendices}
\section{\label{sec_appa}Increase in unemployment }
%renumber appendix tables
\setcounter{table}{0}
\renewcommand{\thetable}{1A\arabic{table}}
\begin{table}[!h]
\centering
\caption{\textbf{table 1}}
\begin{tabular}{rrrrr}
\hline
& \multicolumn{2}{c}{\textbf{1989}} & \multicolumn{2}{c}{\textbf{1992}} \\
\hline
& income1 & expenses1 & income2 & expenses2 \\
\hline
\end{tabular}%
\label{tab:apptab1}%
\end{table}%
% Appendix 1B
\section{\label{sec_appb}Increase in unemployment }
%renumber appendix tables
\setcounter{table}{0}
\renewcommand{\thetable}{1B\arabic{table}}
\begin{table}[!h]
\centering
\caption{\textbf{table 1}}
\begin{tabular}{rrrrr}
\hline
& \multicolumn{2}{c}{\textbf{1989}} & \multicolumn{2}{c}{\textbf{1992}} \\
\hline
& income1 & expenses1 & income2 & expenses2 \\
\hline
\end{tabular}%
\label{tab:apptab2}%
\end{table}%
\end{subappendices}
% chapter 2
\chapter{chapter2}\label{chp:this is chapter2}
\section{Introduction}
This paper examines
\section{Results}
\par Table \ref{tab:tab1} also indicates. But Appendix Table \ref{tab:apptab1}
\par Table \ref{tab:tab2} also indicates But Appendix Table \ref{tab:apptab2}
\section{\label{sec_conc} Conclusion}
\begin{table}[!h]
\centering
\caption{\textbf{table 1}}
\begin{tabular}{rrrrr}
\hline
& \multicolumn{2}{c}{\textbf{1989}} & \multicolumn{2}{c}{\textbf{1992}} \\
\hline
& income1 & expenses1 & income2 & expenses2 \\
\hline
\end{tabular}%
\label{tab:tab1}%
\end{table}%
\begin{table}[!h]
\centering
\caption{\textbf{table 1}}
\begin{tabular}{rrrrr}
\hline
& \multicolumn{2}{c}{\textbf{1989}} & \multicolumn{2}{c}{\textbf{1992}} \\
\hline
& income1 & expenses1 & income2 & expenses2 \\
\hline
\end{tabular}%
\label{tab:tab2}%
\end{table}%
%Appendix
\clearpage
\newpage
\section*{Appendix A}
%\begin{appendices}
\begin{subappendices}
% Appendix 2A
\section{\label{sec_appa}Increase in unemployment }
%renumber appendix tables
\setcounter{table}{0}
\renewcommand{\thetable}{2A\arabic{table}}
%appendix tables
\begin{table}[!h]
\centering
\caption{\textbf{table 1}}
\begin{tabular}{rrrrr}
\hline
& \multicolumn{2}{c}{\textbf{1989}} & \multicolumn{2}{c}{\textbf{1992}} \\
\hline
& income1 & expenses1 & income2 & expenses2 \\
\hline
\end{tabular}%
\label{tab:apptab1}%
\end{table}%
% Appendix 2B
\section{\label{sec_appb}Increase in unemployment}
%renumber appendix tables
\setcounter{table}{0}
\renewcommand{\thetable}{2B\arabic{table}}
%appendix tables
\begin{table}[!h]
\centering
\caption{\textbf{table 1}}
\begin{tabular}{rrrrr}
\hline
& \multicolumn{2}{c}{\textbf{1989}} & \multicolumn{2}{c}{\textbf{1992}} \\
\hline
& income1 & expenses1 & income2 & expenses2 \\
\hline
\end{tabular}%
\label{tab:apptab2}%
\end{table}%
\end{subappendices}
\end{document}
引用表时出现错误。
答案1
我不太清楚你的问题是什么。附录中出现了对表格的引用?那么看看这是否对你有帮助:
在序言中添加包
{chngcntr}
并选择章节内的编号:\usepackage{chngcntr} \counterwithin{table}{section}
添加后
\begin{subappendices}
:\counterwithin{table}{section}
附录中每个部分之后重置表格计数器:
\renewcommand{\thetable}{\arabic{chapter}\Alph{section}.\arabic{table}}
由此我得到以下结果:
这就是你要找的吗?
完整代码(稍微缩短):
\documentclass[12pt,a4paper,twoside]{report}
\usepackage[margin=2.54 cm]{geometry}
\usepackage[titletoc,title]{appendix}
\usepackage{tabularx}
\usepackage{blindtext}
\usepackage{chngcntr}% <----
\counterwithin{table}{section}% <----
\usepackage[hidelinks]{hyperref} % put before apacite
\begin{document}
% chapter 1
\chapter{First chapter}
\label{chp:chapter-1}
\section{Introduction}
This paper examines \dots
\section{Results}
\par Table \ref{tab:tab1} also indicates. But Appendix Table \ref{tab:apptab1}
\par Table \ref{tab:tab2} also indicates But Appendix Table \ref{tab:apptab2}
\section{Conclusion}
\label{sec:conc}
% Tables
\begin{table}[!h]
\centering
\caption{\textbf{table 1}}
\label{tab:tab1}
\begin{tabular}{rrrrr}
\hline
& \multicolumn{2}{c}{\textbf{1989}} & \multicolumn{2}{c}{\textbf{1992}} \\
\hline
& income1 & expenses1 & income2 & expenses2 \\
\hline
\end{tabular}%
%
\end{table}
\begin{table}[!h]
\centering
\caption{\textbf{table 2}}
\label{tab:tab2}
\begin{tabular}{rrrrr}
\hline
& \multicolumn{2}{c}{\textbf{1989}} & \multicolumn{2}{c}{\textbf{1992}} \\
\hline
& income1 & expenses1 & income2 & expenses2 \\
\hline
\end{tabular}
\end{table}%
%Appendix
\clearpage
\newpage
%\section*{Appendix A}
\begin{subappendices}
\renewcommand{\thetable}{\arabic{chapter}\Alph{section}.\arabic{table}}
\section{Increase in unemployment }
\label{sec_appa}
\begin{table}[!h]
\centering
\caption{\textbf{table A1}
\label{tab:apptab1}}
\begin{tabular}{rrrrr}
\hline
& \multicolumn{2}{c}{\textbf{1989}} & \multicolumn{2}{c}{\textbf{1992}} \\
\hline
& income1 & expenses1 & income2 & expenses2 \\
\hline
\end{tabular}%
\end{table}%
% Appendix 1B
\section{Increase in unemployment }
\label{sec_appb}
\begin{table}[!h]
\centering
\caption{\textbf{table B1}}
\label{tab:apptab2}%
\begin{tabular}{rrrrr}
\hline
& \multicolumn{2}{c}{\textbf{1989}} & \multicolumn{2}{c}{\textbf{1992}} \\
\hline
& income1 & expenses1 & income2 & expenses2 \\
\hline
\end{tabular}%
\end{table}%
\end{subappendices}
\end{document}