When writing a thesis, an algorithm framework is used in the following form:
\begin{
algorithm}[H]\label{
alg.l1}
\caption{
算法标题}
\begin{
algorithmic}[1]
\STATE \textbf{
Input:}初始参数输入
\REPEAT
\STATE 算法步骤语句
\UNTIL{
终止条件}
\STATE \textbf{
Output:} 输出解
\end{
algorithmic}
\end{
algorithm}
After using ref{alg.l1} to quote, it will become, Algorithm 2, or Algorithm 3, Algorithm 3.2, etc., depending on which chapter I put this algorithm under. The situation I expect should be displayed as Algorithm 1.
Finally found this article :
Incorrect citation of tables and pictures in some journal templates may occur. For example, the label defined in the first picture is label{fig1}, ref{fig1} is referenced in the tex file, but Figure 2 or Figure xx appears after compilation.
Solution:
In a figure (similar to a table) environment, write caption{} first and then label{}, that is, you must put label{} after caption{}.
So based on my situation, in future articles, in figure, table, algorithm environment (or other environments), label{} can be written after caption{}.