LaTeX新人教程,30分鐘從完全陌生到基本入門
阿新 • • 發佈:2019-02-20
1.LaTeX軟體的安裝和使用
方法A(自助):在MikTeX的官網下載免費的MikTeX編譯包並安裝。下載WinEdt(收費)或TexMaker(免費)等編輯介面軟體並安裝。
方法B(打包):在ctex.org下載ctex套裝(含MikTeX及WinEdt)
哈哈這一部分當然不包含在標題的30分鐘裡。
2.第一個文件
開啟WinEdt,建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8。
\documentclass{article}
\begin{document}
hello, world
\end{document}
然後在WinEdt的工具欄中找到編譯按鈕(在垃圾桶和字母B中間),在下拉選單中選擇XeTeX,並點選編譯。
如果順利的話,我們就可以順利生成出第一個pdf檔案,點選工具欄中的放大鏡按鈕就可以快速開啟生成的pdf檔案。
3.標題、作者和註釋
建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8,編譯並觀察現象。
\documentclass{article}
\author{My Name}
\title{The Title}
\begin{document}
\maketitle
hello, world % This is comment
\end{document}
4.章節和段落
建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8,編譯並觀察現象。
\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的排版結果。
5.加入目錄
建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8,編譯並觀察現象。
\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}
6.換行
建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8,編譯並觀察現象。
\documentclass{article}
\begin{document}
Beijing is
the capital
of China.
New York is
the capital
of America.
Amsterdam is \\ the capital \\
of Netherlands.
\end{document}
7.數學公式
建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8,編譯並觀察現象。
\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}
具體細節可以自行搜尋LaTeX的數學符號表或別人給的例子。
8.插入圖片
先搜尋到一個將圖片轉成eps檔案的軟體,很容易找的,然後將圖片儲存為一個名字如figure1.eps。
建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8,放在和圖片檔案同一個資料夾裡,編譯並觀察現象。
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=4.00in,height=3.00in]{figure1.eps}
\end{document}
9.簡單表格
建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8,編譯並觀察現象。
\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}
10.結尾
到目前為止,你已經可以用LaTeX自帶的article模板來書寫一篇基本的論文框架了,至少你已經能夠用得起來LaTeX了。
在論文從框架到完整的過程中,必然還存在許多的細節問題,比如字型字號,比如圖片拼合,比如複雜的表格等等。
那些問題,就請諮詢google吧。通常來說我們作為初學者會提出的問題,早就已經有許多的先輩們在網路上提過同樣的問題了,看看別人的回答就可以。
LaTeX在國內的普及率並不高,因此許多時候如果搜英文關鍵詞,會獲得更好的效果。
方法A(自助):在MikTeX的官網下載免費的MikTeX編譯包並安裝。下載WinEdt(收費)或TexMaker(免費)等編輯介面軟體並安裝。
方法B(打包):在ctex.org下載ctex套裝(含MikTeX及WinEdt)
哈哈這一部分當然不包含在標題的30分鐘裡。
2.第一個文件
開啟WinEdt,建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8。
\documentclass{article}
\begin{document}
hello, world
\end{document}
然後在WinEdt的工具欄中找到編譯按鈕(在垃圾桶和字母B中間),在下拉選單中選擇XeTeX,並點選編譯。
如果順利的話,我們就可以順利生成出第一個pdf檔案,點選工具欄中的放大鏡按鈕就可以快速開啟生成的pdf檔案。
3.標題、作者和註釋
建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8,編譯並觀察現象。
\documentclass{article}
\author{My Name}
\title{The Title}
\begin{document}
\maketitle
hello, world % This is comment
\end{document}
4.章節和段落
建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8,編譯並觀察現象。
\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的排版結果。
5.加入目錄
建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8,編譯並觀察現象。
\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}
6.換行
建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8,編譯並觀察現象。
\documentclass{article}
\begin{document}
Beijing is
the capital
of China.
New York is
the capital
of America.
Amsterdam is \\ the capital \\
of Netherlands.
\end{document}
7.數學公式
建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8,編譯並觀察現象。
\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}
具體細節可以自行搜尋LaTeX的數學符號表或別人給的例子。
8.插入圖片
先搜尋到一個將圖片轉成eps檔案的軟體,很容易找的,然後將圖片儲存為一個名字如figure1.eps。
建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8,放在和圖片檔案同一個資料夾裡,編譯並觀察現象。
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=4.00in,height=3.00in]{figure1.eps}
\end{document}
9.簡單表格
建立一個新文件,將以下內容複製進入文件中,儲存,儲存型別選擇為UTF-8,編譯並觀察現象。
\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}
10.結尾
到目前為止,你已經可以用LaTeX自帶的article模板來書寫一篇基本的論文框架了,至少你已經能夠用得起來LaTeX了。
在論文從框架到完整的過程中,必然還存在許多的細節問題,比如字型字號,比如圖片拼合,比如複雜的表格等等。
那些問題,就請諮詢google吧。通常來說我們作為初學者會提出的問題,早就已經有許多的先輩們在網路上提過同樣的問題了,看看別人的回答就可以。
LaTeX在國內的普及率並不高,因此許多時候如果搜英文關鍵詞,會獲得更好的效果。