LaTeX簡單使用方法

Content

  • LaTeX的用途
  • LaTeX文件佈局
  • LaTeX的文檔格式
  • 公式環境
  • 圖的排版
  • 表格的排版
  • 有序列表和無序列表
  • 引用
  • 僞代碼
  • 參考文獻

LaTeX的用途

LaTeX是一種基於TeX的排版系統,由美國計算機科學家Leslie Lamport開發。對於生成複雜表格和數學公式,這一點表現得尤其突出。所以它很是適用於生成高印刷質量的科技和數學類文檔。html


LaTeX文件佈局

使用LaTeX生成PDF文檔通常有兩種方式:分佈式

  1. LaTeX -> dvi2pdf -> pdf document
  2. pdfLatex -> pdf document
    一個基本的論文LaTeX文件夾有這樣四個部分,文件佈局以下:
eps          #文件夾用於放論文中使用到的.eps文件
    llncs.cls    #論文模板
    paper.bib    #論文參考文獻
    paper.tex    #論文的正文內容

LaTeX文檔格式

\documentclass{llncs}

\usepackage{graphicx}
%import some packages needed
\graphicspath{{eps/}}    %set eps file path

\renewcommand{\algorithmicrequire}{ \textbf{Input:}}
\begin{document}
\title{My document title}
\titlerunning{xxx}
\author{name1\inst{2} \and name2\inst{1\and 2} \and name3\inst{2} \and name3\inst{2}}
\authorrunning{Amble et al.}
\institute{place1 \email{xxx@xx}\\ \and place2 \email{b@mail}}
\maketitle

\begin{abstract}
\keywords{word1,word2,word3}
\end{abstract}

\section{section1}
\subsection{subsection1.1}

\bibliographystyle{plain}
\bibliography{paper}

\end{document}

公式環境

  • 內聯的公式,即出如今正文中的公式使用$xxx$表示。注意:希臘字母或者任何數學符號必需要在雙美圓符號中間
  • 公式環境,這裏是單獨的公式,須要標號的那種
\begin{equation}
a=b+c
\end{equation}

圖片的排版

圖片使用如下的figure環境,須要導入的宏包:graphicx,而後使用\graphicspath{{eps/}}定義論文配圖的位置工具

\begin{figure}[ht]
\centering
\includegraphics[width=8cm]{picture1.eps}
\caption{The picture title}
\end{figure}
  • h:當前位置
  • b:優先排在底部
  • t:優先排在每頁頂部
  • !:加入感嘆號表示強制性

表格的排版

要引入的包爲multirow,簡單的表格排版可使用以下demo,其中(\\表示換行,\hline表示橫線)。佈局

\begin{table}[!hbp]
\caption{example of table}
\begin{tabular}{|c|c|c|c|c|}
\hline
\hline
lable 1-1 & label 1-2 & label 1-3 & label 1 -4 & label 1-5 \\
\hline
label 2-1 & label 2-2 & label 3-3 & label 4-4 & label 5-5 \\
\hline
\end{tabular}
\end{table}

複雜的多列合併參考以下代碼參考百科。以下:性能

\begin{table}[!hbp]
\caption{example of table}
\begin{tabular}{|c|c|c|c|c|}
\hline
\mutirow{2}{*}{multi-row} & \muticolumn{2}{|c|}{Muti-Column} & multicolumn{2}{|c|}{\multirow{2}{*}{Muti-Row and Muti-Column}}\\
\cline{2-3} & column-1 & \multicolumn{2}{|c|}{}\\
\hline
\end{tabular}
\end{table}

列表

有序列表

導入的宏包爲enumerate,正文中使用以下代碼完成,另外可使用中括號設定標號的格式,例如[(1)]ui

\begin{enumerate}[(1)]
\item this is sentence 1.
\item this is sentence 2.
\end{enumerate}

無序列表

\begin{itemize}
\item this is sentence 1.
\item this is sentence 2.
\end{itemize}

引用

在被引用的地方作以下標記:this

\label{lab1}

在引用的地方使用:spa

\ref{lab1}

僞代碼

導入包:algorithm、algorithmicx和algpseudocode調試

\renewcommand{\algorithmicrequire}{ \textbf{Input:}}
\renewcommand{\algorithmicensure}{ \textbf{Output:}}
\begin{algorithm}
    \caption{algoritm name}
    \begin{algorithmic}[1]
        \Require input parameters
        \Ensure output parameters
        \Function {algorithm name}{input parameters}
            \State $V \gets 0$
            \For{$i \gets 1\quad to\quad len(GramArray)$}
                \State $element \gets GramArray[i]$
                \If{$GramInfo.exist(element)$}
                    \State $GramInfo[element].count++$
                \Else
                    \State $GramInfo.Add(<element,i,1>)$
                \EndIf
            \EndFor
            \While{$GramInfo.isNotEmpty()$}
                \State $cell \gets GramInfo.popElement()$
                \State $index \gets GramMap(cell.gram)$
                \State $V[index] \gets <cell.pos,cell.count>$
            \EndWhile
            \State \Return{$V$}
        \EndFunction
    \end{algorithmic}
\end{algorithm}

參考文獻

在整個\.tex結束的位置,也就是\end{document}以前加入以下代碼:code

\bibliographystyle{plain}
\bibliography{paper}

並單首創建一個.bib文件,該文件中存放參考文獻的資料,具體存放的參考文獻格式能夠利用:

很是方便的獲取。在文章中引用的地方只須要使用以下格式引用便可,這裏須要注意的地方是:須要LaTeX -> bibtex -> LaTeX -> dvi2pdf

\cite{name}

中文處理方法

\documentclass[12pt]{article}
\usepackage{CJK}

\begin{document}
\begin{CJK*}{GBK}{song}
\title{大規模分佈式系統環境下的性能監測與跟蹤調試工具的\\研究成果綜述}
\author{傅海平\footnote{電子郵件: haipingf@gmail.com,學號: 201128013229018}\\
中國科學院計算技術研究所\\}

\date{2012年5月}
\maketitle
\newpage
latex中文排版
\end{CJK*}
\end{document}

才疏學淺,若有不足之處還請多多指教,感激涕零~

相關文章
相關標籤/搜索