2

I have a dissertation with three chapters, and each chapter has the table after main text and appendix. Each appendix has also table. The format is as follows:

    \documentclass[12pt,a4paper,twoside]{report} 
    \begin{document}
    \include{chapter1}
    \include{chapter2}
    \include{chapter3}
    \end{document}

Following is the reproducible example.:

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

There is an error when referencing to the table.

  • I think you have the numbering wrong that you say is output. Instead of the code snippets, we'd appreciate it if you could provide the community with a cohesive minimal working example (MWE). Make it so that we can copy-and-paste-and-compile as see exactly what you're seeing... – Werner Jan 23 '16 at 4:13
  • @Werner I have updated with the reproducible example. Now, the error is in referencing. – Metrics Jan 23 '16 at 5:03
  • What is this error? I test your MWE and it not gives any error. – Zarko Jan 23 '16 at 6:12
  • The error is in referencing Table. In both chapters, we have Table 2.3 also indicates. But Appendix Table 2A1; it should be Table 1.1 also indicates. But Appendix Table 1A1 for chapter 1, and Table 2.1 also indicates. But Appendix Table 2A1 should be chapter 2. – Metrics Jan 23 '16 at 6:25
  • 3
    @Metrics: The obvious problem here is that you can't use the same \label in two different locations. LaTeX mentions this by giving the Warning: There were multiply-defined labels.. – Werner Jan 23 '16 at 6:45
1

I'm not very sure what is your problem. Appearing of references to table in appendix? So see, if this will help you:

  • in preamble add package {chngcntr} and select numbering within section:

    \usepackage{chngcntr} \counterwithin{table}{section}

  • after \begin{subappendices} add:

    \counterwithin{table}{section}

  • after each section in appendices reset table counter:

    \renewcommand{\thetable}{\arabic{chapter}\Alph{section}.\arabic{table}}

With this I obtain the following result:

enter image description here

Is this what you looking for?

Complete code (slightly shortened):

\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}
  • If you add another chapter, you will notice the problem. But, as @Werner said, I probably need to change label. Anyway, thank you for your answer. – Metrics Jan 23 '16 at 14:36
  • Where to add another chapter? Given example doesn't exhibits any problem with referencing regardless on number of chapters. Of course, labels should be unique. That is basic requirements for use referencing!. – Zarko Jan 23 '16 at 14:42
  • You are correct. That was my problem. Once again, thank you for your solution. I will mark it as correct. – Metrics Jan 23 '16 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.