Latex常用功能記錄
阿新 • • 發佈:2018-11-09
圖片插入
根據構建命令不同需要不同格式的圖片
PdfLaTeX可以用png jpg pdf等
本文介紹LaTeX + dvips + ps2pdf,圖片格式必須是eps或ps
\usepackage{epsfig}
\epsfig{figure=f1.eps,scale=1}
演算法插入
常用演算法格式的插入
巨集包algorithm2e:
\usepackage[linesnumbered,ruled]{algorithm2e} %%巨集包進行配置 \IncMargin{1em} \begin{algorithm} \SetAlgoNoLine \SetKwInOut{Input}{\textbf{input}} \SetKwInOut{Output}{\textbf{output}} \Input{ The request for $content$\;\\} \Output{ $Pkt = out$\;\\} \BlankLine my line one \; and this is my second line\; \Repeat {\text{overflow}} {add a triple $additon$\; \For {pkt $\leq$ $threshold$}{ $pkt \leftarrow threshold$ } } \eIf{understand}{ go to next section\; current section becomes this one\; }{ go back to the beginning of current section\; } \caption{Learning algorithm2e\label{al3}} \end{algorithm} \DecMargin{1em}
例項
巨集包algorithm
和algorithmic:
\usepackage{algorithm, algorithmic} \begin{algorithm} \renewcommand{\algorithmicrequire}{\textbf{Input:}} \renewcommand{\algorithmicensure}{\textbf{Output:}} \caption{Learning Macro algorithm $\&$ algorithmic} \label{alg:1} \begin{algorithmic}[1] \REQUIRE a request for $content$ \ENSURE $Pkt$ \STATE My Line One \STATE And this is the second \FOR {$ pkt \in D_{p}$} \IF{$content < threshold$} \STATE $swap(threshold, content)$ \ENDIF \STATE Update $pkt$ based on threshold \ENDFOR \STATE \textbf{return} $pkt$ \end{algorithmic} \end{algorithm}
分欄佈局
注意multicols預設先填滿左欄,但是在最後一頁會預設左右均衡填充
\begin{multicols}{2}
...
\end{multicols}
左對齊:
\begin{flushleft}
...
\end{flushleft}
居中:
\begin{center}
...
\end{center}
右對齊:
\begin{flushright}
...
\end{flushright}
兩端對齊:
\justifying ... \justifying
文字格式
換行:
// %%自動換行,無法用於段落開頭
~~\\ %%段落開頭自動換行