Re: [問題] 縮排問題
※ 引述《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
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
LaTeX 近期熱門文章
PTT數位生活區 即時熱門文章
14
30