我正在尝试缩进\usepackage{algorithm}
模式,但是它不起作用。
我需要使用\usepackage{algorithm}
日志,因为这个论坛上还有其他答案使用其他不适用于此处的包。
\begin{algorithm}
\caption{Analytically computing $X_{1:n}$}
\label{analcomputex1n}
\begin{algorithmic}[1]
\Function{ComputeMinimum}{$n, \widetilde{\bm{p}}, \widetilde{\bm{B}}, \widetilde{\bm{Y}} $}
%\Comment{The g.c.d. of a and b}$
\State $\bm{B}_n \gets \underbrace{ \widetilde{\bm{B}} \otimes \widetilde{\bm{B}} \otimes \dots \otimes \widetilde{\bm{B}}}_{\mbox{$n$ times}}$
\State $\bm{V}_n = \bm{B}^{-1}_n$
\State $k \gets 1$
\State $X_{1:n} \gets 0$
\For{$i_1 \gets 1, n$}
\For{$i_2 \gets 1, n$}
\State $\cdots$
\For{$i_n \gets 1, n$}
\State $X_{1:n} \gets X_{1:n} + \bm{\wp}_o[1,i_1]$ \newline
\hspace{3cm} $\widetilde{\bm{Y}}[i_1,i_2] \widetilde{\bm{Y}}[i_2,i_{i_2+1}]$ \dots \newline
\hspace{3cm} $\widetilde{\bm{Y}}[i_{n-1},i_{i_n}]\bm{V}_n[k,k]$
\State $k \gets k + 1$
\EndFor
\State $\cdots$
\EndFor
\EndFor
\State \Return $X_{1:n}$
\EndFunction
\end{algorithmic}
答案1
\hspace*
应该可以解决问题。我留下了你的3cm
。具体值由你选择。
\documentclass{article}
\usepackage{algpseudocode}
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{amsmath,amssymb}
\def\bm#1{\boldmath{#1}}
\begin{document}
\begin{algorithm}
\caption{Analytically computing $X_{1:n}$}
\label{analcomputex1n}
\begin{algorithmic}[1]
\Function{ComputeMinimum}{$n, \widetilde{\bm{p}}, \widetilde{\bm{B}}, \widetilde{\bm{Y}} $}
%\Comment{The g.c.d. of a and b}$
\State $\bm{B}_n \gets \underbrace{ \widetilde{\bm{B}} \otimes \widetilde{\bm{B}} \otimes \dots \otimes \widetilde{\bm{B}}}_{\mbox{$n$ times}}$
\State $\bm{V}_n = \bm{B}^{-1}_n$
\State $k \gets 1$
\State $X_{1:n} \gets 0$
\For{$i_1 \gets 1, n$}
\For{$i_2 \gets 1, n$}
\State $\cdots$
\For{$i_n \gets 1, n$}
\State $X_{1:n} \gets X_{1:n} + \bm{\wp}_o[1,i_1]$ \newline
\hspace*{3cm} $\widetilde{\bm{Y}}[i_1,i_2] \widetilde{\bm{Y}}[i_2,i_{i_2+1}]$ \dots \newline
\hspace*{3cm} $\widetilde{\bm{Y}}[i_{n-1},i_{i_n}]\bm{V}_n[k,k]$
\State $k \gets k + 1$
\EndFor
\State $\cdots$
\EndFor
\EndFor
\State \Return $X_{1:n}$
\EndFunction
\end{algorithmic}
\end{algorithm}
\end{document}