我想引用算法1,但时这里默认引用的算法编号是章节号,应该如何设置?

\documentclass{article}
\usepackage{algorithm}  
\usepackage{algpseudocode}  
\usepackage{amsmath}  
\renewcommand{\algorithmicrequire}{\textbf{Input:}}  % Use Input in the format 
%of Algorithm  
\renewcommand{\algorithmicensure}{\textbf{Output:}} % Use Output in the format 
\usepackage[section]{placeins}                     

\begin{document}
\section{Introduction}
\section{Preliminaries}
\section{Models}
\subsection{Notations}

  \begin{algorithm}[htb]   \label{myAlg}
    \caption{ Framework of ensemble learning for our system.}  
    \label{alg:Framwork}  
    \begin{algorithmic}[2]  
        \Require  
        The set of positive samples for current batch, $P_n$;  
        The set of unlabelled samples for current batch, $U_n$;  
        Ensemble of classifiers on former batches, $E_{n-1}$;  
        \Ensure  
        Ensemble of classifiers on the current batch, $E_n$;  
        \State Extracting the set of reliable negative and/or positive samples 
        $T_n$ from $U_n$ with help of $P_n$;  
        \label{code:fram:extract}  
        \State Training ensemble of classifiers $E$ on $T_n \cup P_n$, with 
        help of data in former batches;  
        \label{code:fram:trainbase}  
        \State $E_n=E_{n-1}cup E$;  
        \label{code:fram:add}  
        \State Classifying samples in $U_n-T_n$ by $E_n$;  
        \label{code:fram:classify}  
        \State Deleting some weak classifiers in $E_n$ so as to keep the 
        capacity of $E_n$;  
        \label{code:fram:select} \\  
        \Return $E_n$;  
    \end{algorithmic}  
\end{algorithm}  

\section{conclusion}

In this paper, we designed an Algorithm \ref{myAlg}.
\end{document}

2 回答2

1
建议把 `label` 写在 `caption` 后面
  • 感谢! – state123 2019-12-10 21:07 回复
0
你引用的就是章节号,`\label{myAlg}` 是给`\subsection` 的,`\label{alg:Framwork}` 才是给 algorithm 的`\caption`,所以你应该用`\ref{alg:Framwork}` 才对。
  • 好的,谢谢! – state123 2019-12-10 21:07 回复

你的回答

请登录后回答

你的回答将会帮助更多人,请务必认真回答问题。