作者eieio (好多目标)
看板LaTeX
标题Re: [问题] 缩排问题
时间Thu Apr 26 05:54:46 2007
※ 引述《Hoare (boring)》之铭言:
: 我想要在figure中写一段演算法
: ---------------------------------- %这是水平线
: for(int i=0:n)
: i++;
: end
: ---------------------------------- %这是水平线
: figure 1: A simple algorithm
: 我的tex如下
: \documentclass{article}
: \begin{document}
: \begin{figure}
: for(int i=0:n)\\
: ~~i++\\
: end\\
: \caption{A simple algorithm}
: \end{figure}
: \end{document}
: 但i++好像那里好像不能插入空白,但如果把~~放在for前面,它就真的会有两个空白
: 请问要怎麽修改呢?还有要怎麽弄出水平线呢?
建议使用 algorithm 和 algorithmic 的 package
\usepackage[boxed]{algorithm} % boxed 这个选项可以不要
\usepackage[noend]{algorithmic} % noend 这个选项可以不要
\begin{algorithm}[htbp]
\caption{A simple algorithm}
\begin{algorithmic}[1]
\FOR {int $i=0:n$}
\STATE $i++$
\ENDFOR
\end{algorithmic}
\end{algorithm}
--
If I don't know I don't know, I think I know
If I don't know I know, I think I don't know
── R. D. Laing
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 138.23.204.19