For循环在算法中无法正常工作

For循环在算法中无法正常工作

示例和输出已附上

         \documentclass[journal]{IEEEtran}
        \IEEEoverridecommandlockouts
      \usepackage{url}
    \usepackage{footnote}
        \usepackage{tablefootnote}
        \usepackage{amsmath,amssymb,amsfonts}
    \usepackage{diagbox}
       \usepackage{csquotes}
      \usepackage{algorithmic}
      \usepackage{graphicx}
       \usepackage{subfig}
       \usepackage[linesnumbered,ruled,vlined]{algorithm2e}
      \usepackage{hyperref}
      \usepackage{float,caption}

     \renewcommand{\arraystretch}{1.5}
     \setlength{\tabcolsep}{4pt}
         \usepackage{textcomp}
        % \usepackage{subfloat}
         \usepackage{caption}% http://ctan.org/pkg/caption
        \usepackage{xcolor}
        \def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
            T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
        \providecommand{\nr}[1]{\textcolor{red}{[{\bf #1}]}}
      \newcommand{\subparagraph}{}
        \usepackage[compact]{titlesec}  

     \usepackage{soul}
     \usepackage{makecell}

     \renewcommand\theadalign{bc}
     \renewcommand\theadfont{\bfseries}
     \renewcommand\theadgape{\Gape[4pt]}
          \renewcommand\cellgape{\Gape[4pt]}


         \begin{document}     


     \begin{algorithm}
       \textbf{Given}: A    \\
     \KwIn{B} \\
         \textbf{Output}: C \\
       \textbf{Initialization}: D  \\
      \Repeat {(t=M)}{% 
        \textbf{\ul{Training $IP_{o}N$}} \\
       \For{$i=1$:$T$}  \\
       \State{Update $\hat{f_{c}}$ using Eq~\eqref{eq:3}}\\

              \For{$f_{c}$= $\hat{f_{c}^t}$} \\
             \State{Y}} \\


      \Repeat {(t=M)}{% 
        \textbf{\ul{Training $IP_{o}N$}} \\
           \For{$i=1$:$T$}  \\
              \For{$\phi_{2}$= $\hat{\phi_{2}^t}$} \\
              \State{X} \\
             \End
          \End
     }
       $\hat{\phi_{1}}$ \leftarrow $\phi_{1}^t$, $\hat{\phi_{2}}$ \leftarrow $\phi_{2}^t$ and 
        $\hat{f_{c}}$ \leftarrow $f_{c}^t$ \\
      % Output Reconstructed Image $\hat{f}(x,y)$ \\
      \caption{FF}
      \label{algo:algorithm}
          \end{algorithm}
\end{document}

在此处输入图片描述

答案1

类似这样的事?

\documentclass[journal]{IEEEtran}

\IEEEoverridecommandlockouts

\usepackage{url}
\usepackage{footnote}
\usepackage{tablefootnote}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{diagbox}
\usepackage{csquotes}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}

\usepackage{float}

\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{4pt}
\usepackage{textcomp}

\usepackage{caption}% http://ctan.org/pkg/caption
\usepackage{xcolor}
        \def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
            T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
        \providecommand{\nr}[1]{\textcolor{red}{[{\bf #1}]}}
      \newcommand{\subparagraph}{}
\usepackage[compact]{titlesec}  

\usepackage{soul}
\usepackage{makecell}

\usepackage{hyperref} % <=========== last package to be called here

\renewcommand\theadalign{bc}
\renewcommand\theadfont{\bfseries}
\renewcommand\theadgape{\Gape[4pt]}
\renewcommand\cellgape{\Gape[4pt]}


\begin{document}     

\begin{algorithm}
  \textbf{Given}: A    \\
  \KwIn{B} 
  \textbf{Output}: C \\
  \textbf{Initialization}: D  \\
  \Repeat {(t=M)}{% 
    \textbf{\ul{Training $IP_{o}N$}} \\
    \For{$i=1$:$T$}{  
      \textbf{Update $\hat{f_{c}}$ using Eq~\eqref{eq:3}}\\
      \For{$f_{c}$= $\hat{f_{c}^t}$}{ 
        \textbf{Y}
      }
    }
  } 

  \Repeat {(t=M)}{% 
    \textbf{\ul{Training $IP_{o}N$}} \\
    \For{$i=1$:$T$}{  
        \For{$\phi_{2}$= $\hat{\phi_{2}^t}$}{ 
          \textbf{X} 
        }
    }
  }
  $\hat{\phi_{1}} \leftarrow \phi_{1}^t$, $\hat{\phi_{2}} \leftarrow \phi_{2}^t$ and 
  $\hat{f_{c}} \leftarrow f_{c}^t$ \\
      % Output Reconstructed Image $\hat{f}(x,y)$ \\
  \caption{FF}
  \label{algo:algorithm}
\end{algorithm}
\end{document}

其结果

生成的 pdf

相关内容