一般註解
%
多行註解
\usepackage{comment}
%不能縮排,要貼在最左邊
\begin{comment}
\end{comment}
粗體
{\bf This is boldface.}
斜體
{\it This is italic.}
換行
\\
\newline
不換段落
\noindent
小寫羅馬字母
{\romannumeral 數字}
大寫羅馬字母
\uppercase\expandafter{\romannumeral 數字}
表格
\begin{table}[h]
\caption{Main symbols and definitions}
\label{table symbols}
\centering
\begin{tabular}{|c|l|}
\hline
Symbol & Definition \\\hline
\end{tabular}
\end{table}
插入圖片(PDF檔並置於同資料夾)
\begin{figure}[h]
\centering
\includegraphics[width=9cm]{檔名}\\
\caption{An example for introducing algorithms.}\label{fig example}
\end{figure}
引用
Fig.~\cite{label name}
LaTex數學公式 維基百科
裡頭包含了大部分的特殊符號
一般段落中使用數學符號,會變斜體
$text$
使數學式子獨立成一行
\[ 數學式子\]
這也會是獨立一行,會有編號,equation* 則不附編號
\begin{equation}
數學式子
\end{equation}
下標
A_1
上標
A^1
空集合(有三種選擇)
\emptyset
\phi
\varnothing
整段數學,不附編號
\[
\begin{aligned}
& 左邊右邊都要用符號夾住表換行 \quad 縮排\\
\end{aligned}
\]
我使用的是algorithm2e
詳細介紹可見手冊
algorithm2e.sty — package for algorithms
最前面要先引用
\usepackage[ruled,lined,linesnumbered,]{algorithm2e}
我用的是
ruled、lined、linesnumbered
可以在algorithm2e手冊P.19頁中尋找自己喜歡的樣式
還有可以將演算法中的註解更改樣式
最前面加入
%set color to comment
\newcommand
\mycommfont[1]{\footnotesize\ttfamily\textcolor{blue}{#1}}
\SetCommentSty{mycommfont}
演算法中加入
\tcp*[f]{Point i is with obstacle}
完整範例
\begin{algorithm}
\SetKwInOut{Input}{input}
\SetKwInOut{Output}{output}
%\Indm
\Input{The photo with indoor information}
\Output{The location NO. of obstacles}
%\Indp
\BlankLine
map(point,color) $\leftarrow$ RGB color of points\\
\tcp*[f]{color: 1,red. 2,green. 3,blue.}\\
floor\_r $\leftarrow$ red color of the floor\\
floor\_g $\leftarrow$ green color of the floor\\
floor\_b $\leftarrow$ blue color of the floor\\
num $\leftarrow$ amount of points\\
obs $\leftarrow$ Obstacles\\
\For{i = 1:num}
{
red(i) \tcp*[f]{R color of point i}\\
green(i) \tcp*[f]{G color of point i}\\
blue(i) \tcp*[f]{B color of point i}\\
\eIf{ $| red(i)-floor\_r |$ $>$ 60 or $| green(i)-floor\_g |$ $>$ 60 or $| blue(i)-floor\_b |$ $>$ 70}
{ \label{code color}
obs $\leftarrow$ i \tcp*[f]{Point i is with obstacle}\\
map(i,1) $\leftarrow$ 255 \tcp*[f]{set Point i to the red}\\
map(i,2) $\leftarrow$ 1\\
map(i,3) $\leftarrow$ 1\\
}
{
map(i,1) $\leftarrow$ 1 \tcp*[f]{set point i to the black}\\
map(i,2) $\leftarrow$ 1\\
map(i,3) $\leftarrow$ 1\\
}
}
\Return obs
\caption{Image Processing}\label{alg Image Processing}
\end{algorithm}
結果如下