[問題] algorithmic package

看板LaTeX (論文排版)作者 (好多目標)時間17年前 (2008/02/10 06:50), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/3 (看更多)
使用 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
文章代碼(AID): #17hYuyL8 (LaTeX)
討論串 (同標題文章)
文章代碼(AID): #17hYuyL8 (LaTeX)