LATEX教程(一) 第一个文档 标题、作者和注释 章节和段落 加入目录 换行 数学公式

打开WinEdt,建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8。

documentclass{article}
egin{document}
   hello, world
end{document}

标题、作者和注释

documentclass{article}

usepackage{Ctex}

author{yif}

itle{我是标题}

egin{document}

maketitle

我是yif % This is comment

end{document}

章节和段落

documentclass{article}
usepackage{Ctex} 
      	itle{我是标题}
    author{yif} 
egin{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}

加入目录

documentclass{article} 
usepackage{Ctex}
egin{document} 
   	ableofcontents %生成目录
   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}

换行




documentclass{article} 
usepackage{Ctex}
	itle{我的标题}
author{yif}
    egin{document} 
maketitle 
   Beijing is 
   the capital 
   of China. 

  Washington is 

   the capital 

   of America. 

   Amsterdam is \ the capital \ 
   of the Netherlands. 
    end{document}

换一行不会显示换行,进行换两行在显示时才显示换一行。

双斜杠换行

数学公式

documentclass{article} 
       usepackage{amsmath} 
       usepackage{amssymb}
    usepackage{Ctex}
    	itle{我的标题}
    author{yif} 
egin{document} 
maketitle
   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$ %b是a的下标

   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[ 
       egin{array}{lcr} 
         a1 & b22 & c333 \ 
         d444 & e555555 & f6 
       end{array} 
     
ight] 
   ] 

Equations(here & is the symbol for aligning different rows) %写&
egin{align} 
   a+b&=c\ %公式后面显示标号
   d&=e+f+g %公式后面显示标号
end{align} 

[ %带前括号
   left{ 
     egin{aligned} 
       &a+b=c\ 
       &d=e+f+g 
     end{aligned} 
   
ight. 
]

end{document}