Latex使用简单总结
安裝完Latex后會有這幾個工具:
AAAAA:第一部分-->基礎篇
(1)打開圖中TeXworks editor,出現如下界面:
在菜單欄下方空白處可進行編輯自己的內容。
(2)從最簡單的編輯一個hello word開始。
\documentclass{article}
\begin{document}
hello, world
\end{document}
把上述內容復制到Tex下。
首先點擊文件-->另存為-->保存到Tex(該文件夾是提前建好存放在某個目錄下的),該步執行結果如下:
其次,點擊,會直接生成pdf版本,該pdf內容就是你上述編輯的hello,word
最后,在你保存的文件夾tex下會有幾個文檔,其中包含生成的pdf文檔。
至此,一個簡單的pdf版本就生成了。
AAAAA:第二部分-->進階
1.標題、作者和注釋
\documentclass{article}
\author{My Name}
\title{The Title}
\begin{document}
\maketitle
hello, world % This is comment
\end{document}
2.章節和段落
\documentclass{article}
\title{Hello World}
\begin{document}
\maketitle
\section{Hello China} China is in East Asia.
\subsection{Hello Beijing} Beijing is the capital of China.
\subsubsection{Hello Dongcheng District}
\paragraph{Tian'anmen Square}is in the center of Beijing
\subparagraph{Chairman Mao} is in the center of Tian'anmen Square
\subsection{Hello Guangzhou}
\paragraph{Sun Yat-sen University} is the best university in Guangzhou.
\end{document}
退格只是我個人偏好,看起來層次清晰美觀。實際操作上未必要如此,每一行之前的空格不影響編譯生成PDF的排版結果。
3.加入目錄
\documentclass{article}
\begin{document}
\tableofcontents
\section{Hello China} China is in East Asia.
\subsection{Hello Beijing} Beijing is the capital of China.
\subsubsection{Hello Dongcheng District}
\paragraph{Hello Tian'anmen Square}is in the center of Beijing
\subparagraph{Hello Chairman Mao} is in the center of Tian'anmen Square
\end{document}
4.換行
\documentclass{article}
\begin{document}
Beijing is
the capital
of China.New York isthe capitalof America.Amsterdam is \\ the capital \\
of Netherlands.
\end{document}
5.數學公式
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
The Newton's second law is F=ma.The Newton's second law is $F=ma$.The Newton's second law is
$$F=ma$$The Newton's second law is
\[F=ma\]Greek Letters $\eta$ and $\mu$Fraction $\frac{a}{b}$Power $a^b$Subscript $a_b$Derivate $\frac{\partial y}{\partial t} $Vector $\vec{n}$Bold $\mathbf{n}$To time differential $\dot{F}$Matrix (lcr here means left, center or right for each column)
\[
\left[
\begin{array}{lcr}
a1 & b22 & c333 \\
d444 & e555555 & f6
\end{array}
\right]
\]Equations(here \& is the symbol for aligning different rows)
\begin{align}
a+b&=c\\
d&=e+f+g
\end{align}\[
\left\{
\begin{aligned}
&a+b=c\\
&d=e+f+g
\end{aligned}
\right.
\]\end{document}
6.插入圖片(先搜索到一個將圖片轉成eps文件的軟件,很容易找的,然后將圖片保存為一個名字如figure1.eps。 建立一個新文檔,將以下內容復制進入文檔中,保存,保存類型選擇為UTF-8,放在和圖片文件同一個文件夾里,編譯并觀察現象。)
準備一張圖片giraffe.eps,放到你所建立的Tex文件夾下,
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=4.00in,height=3.00in]{giraffe.eps}
\end{document}
一個在線的png2eps的轉換工具:http://www.tlhiv.org/rast2vec/
7.簡單表格
\documentclass{article}
\begin{document}
\begin{tabular}{|c|c|}
a & b \\
c & d\\
\end{tabular}\begin{tabular}{|c|c|}
\hline
a & b \\
\hline
c & d\\
\hline
\end{tabular}\begin{center}
\begin{tabular}{|c|c|}
\hline
a & b \\ \hline
c & d\\
\hline
\end{tabular}
\end{center}
\end{document}
AAAAA:擴展
1.中文支持
曾經的LaTeX的中文支持是比較麻煩的一件事,但是現在使用MikTeX+WinEdt的中文支持非常容易。
只需要把開頭的\documentclass{atricle}換成\documentclass{ctexart}就可以了。
如果是第一次使用ctexart的話,會自動下載和安裝宏包和模板,之后就不會再下載了。
例子參考如下:
打開WinEdt,建立一個新文檔,將以下內容復制進入文檔中,保存,保存類型選擇為UTF-8。
\documentclass{ctexart}
\begin{document}
你好,世界
\end{document}
2.宏包
\package{}就是在調用宏包,對計算機實在外行的同學姑且可以理解為工具箱。
每一個宏包里都定義了一些專門的命令,通過這些命令可以實現對于一類對象(如數學公式等)的統一排版(如字號字形),或用來實現一些功能(如插入圖片或制作復雜表格)。
通常在\documentclass之后,在\begin{document}之前,將文章所需要涉及的宏包都羅列上。
對于新人而言比較常用的宏包有
編輯數學公式的宏包:\usepackage{amsmath}和 \usepackage{amssymb}
編輯數學定理和證明過程的宏包:\usepackage{amsthm}
插入圖片的宏包:\usepackage{graphicx}
復雜表格的宏包:\usepackage{multirow}
差不多了,對于新人來說,這五個宏包已經基本夠用了。如果有其他的特殊需求,就通過google去尋找吧。
補充說明一下,現在ctexart模板里集成了中文支持,所以CJK宏包并不是必需品。
3.模板
模板就是在\documentclass{}后面的大括號里的內容。
在這一份教程中,我們使用的是LaTeX默認自帶的模板article,以及中文模板ctexart。
模板就是實現我之前所介紹的LaTeX的經驗總結的第二點的實現方式。
一篇文章,我們定義了section,定義了paragraph,就是沒有定義字體字號,因為字體字號這一部分通常來說是在模板中實現的。
一個模板可以規定,section這個層級都用什么字體什么字號怎么對齊,subsection這個層級用什么字體什么字號怎么對齊,paragraph又用什么字體什么字號怎么對齊。
當然模板里還可以包含一些自定義的口令,以及頁眉頁腳頁邊距一類的頁面設置。
由于模板的使用,在我的使用經驗里來看,絕對不可能算是基本入門級的內容,所以在正文里當然不會提及。
如果有人實在想學,如果LaTeX已經接觸到這個程度上了,那么再去翻其他厚一些的教材,也不虧了。
4.參考文獻和制作幻燈片
做參考文獻的時候,文章也已經快寫到尾聲了,而幻燈片更不是進階一些的需求。對這兩個功能有需求的LaTeX user,使用LaTeX也已經相當熟練了,自己去google一下或查閱其他厚教程是很理所當然的,一點也不冤枉。
在此我就只提供兩個搜索關鍵詞,參考文獻可以搜bibtex,制作幻燈片可以搜beamer。
總結
以上是生活随笔為你收集整理的Latex使用简单总结的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PCL显示法线no override f
- 下一篇: PCL分割:Conditional Eu