Re: [問題] algorithmic package
※ 引述《eieio (好多目標)》之銘言:
: 使用 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]}
文件上有說唷!
Because the mechanisms used to build the various algorithmic structures make
it difficult to use the above mechanism for placing comments at the end of
the first line of a construct, the commands \IF, \ELSIF, \ELSE, \WHILE, \FOR,
\FORALL, \REPEAT and \LOOP all take an optional argument which will be treated
as a comment to be placed at the end of the line on which they appear.
他說應該要變成這樣 \IF{OOO} [XXX]
[]裡面的是註解!
希望有幫上忙^^
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.30.45
→
02/10 13:04, , 1F
02/10 13:04, 1F
討論串 (同標題文章)
LaTeX 近期熱門文章
PTT數位生活區 即時熱門文章