開始在論文寫作中使用Latex,整理一下手冊中常用的以及在網上搜集到的一些資料,以便以后查閱。
\textrm 公式里面出現文本格式
\label{} 加標簽
\ref{} 引用
\eqref{} 公式引用
\mathbf{} 粗體(數學符號)
\textbf{} 粗體(文本)
\emph{} 斜體強調
公式的編輯可以借助在線公式編輯器,所見即所得
http://zh.numberempire.com/texequationeditor/equationeditor.php
插入算法
參照 http://www.ctex.org/documents/packages/verbatim/index.htm 中的algorithms章節,下面舉例說明需要注意的幾點
首先引入幾個需要用到的包
\usepackage{algorithm} %format of the algorithm
\usepackage{algorithmic} %format of the algorithm
\usepackage{multirow} %multirow for format of table
\usepackage{amsmath}
\usepackage{xcolor}
重新定義require和ensure命令對應的關鍵字(此處將默認的Require/Ensure自定義為Input/Output)
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
分析一下示例:
\begin{algorithm} %算法開始
\caption{Sample algorithm} %算法的題目
\label{alg1} %算法的標簽
\begin{algorithmic}[1] %此處的[1]控制一下算法中的每句前面都有標號
\REQUIRE Text:Today is a good day. Variables:$u,v,w$. $G=(V,E)$ %輸入條件(此處的REQUIRE默認關鍵字為Require,在上面已自定義為Input)
\ENSURE Something... %輸出結果(此處的ENSURE默認關鍵字為Ensure在上面已自定義為Output)
% if-then-else
\IF{some condition is true}
\STATE do some processing
\ELSIF{some other condition is true}
\STATE do some different processing
\ELSE
\STATE do the default actions
\ENDIF
% for loop
\FOR{$i=0$ to $10$}
\STATE carry out some processing
\ENDFOR
\FORALL{$i$ such that $0\leq i\leq 10$}
\STATE carry out some processing
\ENDFOR
% while-loop
\WHILE{some condition holds}
\STATE carry out some processing
\ENDWHILE
% repeat-until loop
\REPEAT
\STATE carry out some processing
\UNTIL{some condition is met}
% infinite loop
\LOOP
\STATE this processing will be repeated forever
\ENDLOOP\end{algorithmic}
\end{algorithm}
輸出結果如下所示:
先記到這里,附上幾個有用的鏈接
學習LaTeX http://latex.yo2.cn/articles/latex-learning12.html
CTEX - 在線文檔 - TeX/LaTeX 常用宏包 http://www.ctex.org/documents/packages/verbatim/index.htm
Latex在線公式編輯器 http://zh.numberempire.com/texequationeditor/equationeditor.php