I am using a .sty file from my university to prepare my dissertation. In this file, there is a float for "Algorithms" that I use to define
Algorithm 1, Algorithm 2, ...
My problem is that, no matter what the labels of my algorithms in the appendix section are, when I call them, their reference number is linked to algorithms in the main body, as opposed to the algorithms that they belong to.
After doing some research, I realized that there are parts of the .sty file that govern how the "List of Algorithms" are organized. This file creates a file with extension .lom that keeps all information about the algorithm list. In this file, the labels of appendix algorithms are linked to algorithms in the body! Please find below parts of the .sty file that talk about "List of Algorithms" rules. I am wondering if someone can help me with debugging these lines.
\def\listofalgorithms{%
\newpage
\addcontentsline{toc}{chapter}{LIST OF ALGORITHMS}
\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn\fi
\hbox{ }
\twoinmar
\centerline{\large\bf LIST OF ALGORITHMS}
\vspace{0.7in}
\begin{doublespace}
\@starttoc{lom}\if@restonecol\twocolumn\fi
\addtocontents{lom}{\noindent\underline{\bf Algorithm}\hfill\rm\protect\newline}
\end{doublespace}
\pagestyle {empty}
}
\newcounter{algorithm}[chapter]
\def\thealgorithm{\@arabic\c@chapter.\@arabic\c@algorithm}
\def\fps@algorithm{tbp}
\def\ftype@algorithm{1}
\def\ext@algorithm{lom}
\def\fnum@algorithm{Algorithm\thealgorithm}
\def\algorithm{\@float{algorithm}}
\let\endalgorithm\end@float
\@namedef{algorithm*}{\@dblfloat{algorithm}}
\@namedef{endalgorithm*}{\end@dblfloat}
\refcommand, when clicked, leads to a different algorithm than the one you intend (to an algorithm in the main text rather than to an algorithm in the appendices). Is this correct? If so, try\newcommand*{\theHalgorithm}{\theHchapter.\arabic{algorithm}}at the end of the preamble. – GuM Jul 09 '15 at 00:09Also thank you Mico and John for your help. I was preparing MWE files that Gustavo solved my problem.
– Salivan Jul 09 '15 at 00:37.styfile your university gave you: say\def\thealgorithm{\thechapter.\arabic{algorithm}}, and also, I’d rather add,\def\ftype@algorithm{4}and\def\fnum@algorithm{Algorithm \thealgorithm}(note the space before\thealgorithm!). – GuM Jul 09 '15 at 00:47