for 루프를 들여쓰는 방법

for 루프를 들여쓰는 방법

다음과 같은 알고 코드가 있습니다

\begin{algorithm}[t]
    \caption{my algo}
    \label{my algo}
     \begin{algorithmic}[] 
        \State \textbf{Input:}{ abc}
        \State \textbf{Output:}{ xyz}
        \State \textbf{Launch:}{I want to indent the body of this algo afterwards }
        % I want to indent the following body:
        \For{i=0,i<5,i++}
        \For {j=0,i<5,j++ }
        \State{Kill}
            \State{Now}
            \State{There}
             \If {this}
             \State{then this}}
            
        \EndIf    
        \For {z=0,z<10,z++ }
        \State{Action performed on z}
        \EndFor
        \State{abc processed }
        \State{xyz produced}
               
    \EndFor
    % \State{processing done}
    \EndFor
    \end{algorithmic}
   \end{algorithm} 

세 번째 "State" 문 다음에 for 루프부터 시작하여 알고리즘 본문을 들여쓰고 싶습니다. 어떻게 해야 합니까? 현재 for 루프는 "Launch" 문 바로 아래에서 시작됩니다.

답변1

이 트릭으로 동일한 문제를 해결했습니다( 프로덕션용 \transparent{0.5}으로 변경).\transparent{0}

\begin{algorithm}[!t]
\caption{}\label{}
\begin{algorithmic}

  \STATE whatever

  \transparent{0.5}
  \vspace{-1\baselineskip}
  \IF fake indentation
  \transparent{1}

  \FOR {this for loop gets now indented}
    \STATE whatever
  \ENDFOR

  \transparent{0.5}
  \vspace{-1\baselineskip}
  \ENDIF
  \transparent{1}

\end{algorithmic}
\end{algorithm}

관련 정보