作者eieio (好多目标)
看板LaTeX
标题[问题] algorithmic package
时间Sun Feb 10 06:50:34 2008
使用 algorithmic packge
我在排版 pseudocode 时,希望能有
if xxx then
{yyy}
zzz
这种效果。若是
\IF{xxx}\COMMENT{yyy}
\STATE zzz
\ENDIF
的话,到 \STATE zzz 那行就烂掉了。我去查了 algorithmic.sty,我觉得跟这
有关系的是
\newcommand{\ALC@com}[1]{\ifthenelse{\equal{##1}{default}}%
{}{\ \algorithmiccomment{##1}}}
\newcommand{\IF}[2][default]{\ALC@it\algorithmicif\ ##2\ \algorithmicthen%
\ALC@com{##1}\begin{ALC@if}}
其中 \algorithmiccomment 就是 \COMMENT 的呼叫的东西,\algorithmicif
就只是 \textbf{if},\algorithmicthen 就是 \textbf{then}。\begin{ALC@if}
是用来调 indentation 的 environment。看起来 \IF 可以吃两个参数,所以我
改成
\IF{yyy}{xxx}
\STATE zzz
\ENDIF
仍然获得以下讯息:
! 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.1243 \STATE
zzz
请问有高手可以 解决/解释 这是怎麽回事吗?另外附上 preamble:
\usepackage{algorithm}
\usepackage[noend]{algorithmic}
\algsetup{indent=2em}
\newcommand{\algorithmicinput}{\textbf{Input:}}
\newcommand{\INPUT}{\item[\algorithmicinput]}
\newcommand{\algorithmicoutput}{\textbf{Output:}}
\newcommand{\OUTPUT}{\item[\algorithmicoutput]}
--
Just because you deserve this
doesn't mean they're gonna give it to you.
Sometimes you gotta take what's yours.
── Kenny Ray Carter
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 75.142.222.87