[問題] algorithmic package
使用 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
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 3 篇):
LaTeX 近期熱門文章
PTT數位生活區 即時熱門文章