![我不断收到可能缺少 \item 的错误](https://linux22.com/image/316129/%E6%88%91%E4%B8%8D%E6%96%AD%E6%94%B6%E5%88%B0%E5%8F%AF%E8%83%BD%E7%BC%BA%E5%B0%91%20%5Citem%20%E7%9A%84%E9%94%99%E8%AF%AF.png)
我的 LaTeX 代码有问题。我一直收到错误:
Underfull \vbox (badness 10000) has occurred while \output is active [13]
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.461 \end{algorithmic}
LaTeX 代码:
\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{pifont}
\begin{document}
\begin{algorithm}
\caption{ glavna\_zanka }%function
\begin{algorithmic}[1]
\While{ končaj $\not=$ false }
\State $ rotiraj\_robota()$
\State obrobje o = $izberi\_raziskovalni\_cilj()$
\If { o $\neq$ null }
\State $ premakni\_do\_cilja(o)$
\Else
\State končaj = true
\EndIf
\EndWhile
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\caption{ izberi\_raziskovalni\_cilj() }
\begin{algorithmic}[1]
\end{algorithmic}
\end{algorithm}
\end{document}
我将非常感激您对这个问题的任何见解。
答案1
预期代码主体中有几行代码algorithmic
。请比较一个可编译的示例:
\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{pifont}
\begin{document}
\begin{algorithm}
\caption{ glavna\_zanka }%function
\begin{algorithmic}[1]
\While{ končaj $\not=$ false }
\State $ rotiraj\_robota()$
\State obrobje o = $izberi\_raziskovalni\_cilj()$
\If { o $\neq$ null }
\State $ premakni\_do\_cilja(o)$
\Else
\State končaj = true
\EndIf
\EndWhile
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\caption{ izberi\_raziskovalni\_cilj() }
\begin{algorithmic}[1]
\While
\EndWhile
\end{algorithmic}
\end{algorithm}
\end{document}
顺便说一句:LaTeX Error: Something's wrong--perhaps a missing \item.
很少意味着缺少物品;至少根据我的经验。:-)
答案2
看来算法环境需要有一个内容:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{pifont}
\begin{document}
%
\begin{algorithm}
\caption{ glavna\_zanka }%function
\begin{algorithmic}[1]
\While{ končaj $\not=$ false }
\State $ rotiraj\_robota()$
\State obrobje o = $izberi\_raziskovalni\_cilj()$
\If { o $\neq$ null }
\State $ premakni\_do\_cilja(o)$
\Else
\State končaj = true
\EndIf
\EndWhile
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\caption{izberi\_raziskovalni\_cilj()}
\begin{algorithmic}[1]
\State Lalala…
\end{algorithmic}
\end{algorithm}
\end{document}