我尝试在算法中添加一些空格,但没有任何进展。我做了:
\begin{algorithm}[H]
\caption{Example}
\begin{algorithmic}[2]
\State Init:
\State Example
\end{algorithmic}
\end{algorithm}
正确的做法是什么?
答案1
这样吧,我为你指定了一个新的初始化块结构,如第 14 页
\documentclass{article}
\usepackage{amsmath} %for math
\usepackage{amsfonts} %American math society fonts
\usepackage{gensymb} %Used for symbols such as $\degree$
\usepackage{algorithm}% http://ctan.org/pkg/algorithms
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
\usepackage{algorithmicx}% http://ctan.org/pkg/algorithmicx
\begin{document}
\begin{algorithm}[H]
\algblockdefx[initializeblock]{initialize}{endinitialize}%
[1]{#1}%prints whatever you input
{}%no end line
\caption{Example}
\begin{algorithmic}[2]
\initialize{Init:}
\State Example
\endinitialize
\end{algorithmic}
\end{algorithm}
\end{document}