LoginSignup
27
22

More than 3 years have passed since last update.

LatexでのAlgorithmの書き方(論文、技術報告書)

Posted at

0. 概要

データ解析等をしていると入力→前処理→処理→後処理→出力等と入力から出力を得るまでに複雑な処理をしないといけない場合がありますよね。この時、文章だけではどうしても読者に伝わりづらいことがあります。その時に用いるのが疑似コード、アルゴリズムを用いた文章表現です。

例えばこんなやつです。
Ses4T.png
論文でよく見ますよね。これを使えば処理の流れが説明しやすいです。
ところで、これってどうやって生成するんだ??っていうのを説明していきます。

1. Latexを始める

おもむろにhttps://ja.overleaf.com/へアクセスしてアカウントを作成し、空のプロジェクトを生成する。
image.png
こんな画面が表示されれば、後はLatexを書いていくだけである。

2. Algorithmを作る

取り合えず、IEEEのテンプレートでザックり作ってみる。

\documentclass{IEEEtran}
\usepackage{algorithm,algorithmic}
\begin{document}
 \begin{algorithm}
 \caption{Algorithm for ...}
 \begin{algorithmic}[1]
 \renewcommand{\algorithmicrequire}{\textbf{Input:}}
 \renewcommand{\algorithmicensure}{\textbf{Output:}}
 \REQUIRE in
 \ENSURE  out
 \\ \textit{Initialisation} :
  \STATE first statement
 \\ \textit{LOOP Process}
  \FOR {$i = l-2$ to $0$}
  \STATE statements..
  \IF {($i \ne 0$)}
  \STATE statement..
  \ENDIF
  \ENDFOR
 \RETURN $P$ 
 \end{algorithmic} 
 \end{algorithm}
\end{document}
27
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
22