latex自学笔记(持续更新ing)

前言:之前的一片博客介绍了linux下安装latex,真的强烈推荐在linux下使用latex,因为安装真的就是两句话,而windows下找软件都头疼,运气差都要搞好久呀。

下面就根据师姐的教程和网上的资料慢慢学习,并记录下来。

尤其是下面里的“说明”部分,都是我自己总结的知识点哦。


一、一个简单的文本

打开texmaker,建立一个新文档,将以下内容复制进入文档中,保存。

\documentclass{article} 
\begin{document} 
  hello, world 
\end{document}

然后点击工具栏中的快速构建和查看pdf,编译完成后就可以在右边看到啦。

这里写图片描述

这里写图片描述


二、如何加入标题和作者

将下面的代码进行编译:
这里写图片描述

得到的效果:
这里写图片描述

所以,我们如果要改的话,只需将括号里面的my name和the title改了就行了。

注释就是通过%号实现的,与matlab一样。


三、如何实现章节和起段落

建立一个新文档,将以下内容复制进入文档中,保存

\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} 

效果:
这里写图片描述

说明:
1.这里的 \section{Hello China}就是插入章节的格式,括号里写上章节的题目,接着写在后面的内容就是该章节里的内容。并且后面在用这个代码会自动让章节的编号递增。

2.\subsection{Hello Beijing} 这个代码是用来写子章节的格式,括号里写上子章节的题目,接着写在后面的内容就是该子章节里的内容。并且后面在用这个代码会自动让子章节的编号递增。

3.\subsubsection{Hello Dongcheng District} 这个代码是用来写子子章节的格式,括号里写上子子章节的题目,接着写在后面的内容就是该子子章节里的内容。并且后面在用这个代码会自动让子子章节的编号递增。

4.\paragraph{Tian’anmen Square} 这个是用来重新起段落的代码,但是注意这个\paragraph并不会空两格,而\subparagraph{Chairman Mao}就有空两格。并且注意,写在括号里的内容会被加黑,如果不想被加黑就不要在{}里加内容,就用一个空的{}。


四、如何插入目录

建立一个新文档,将以下内容复制进入文档中,保存:

\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} 

效果:

这里写图片描述

说明:加入目录就是加入了一句话:\tableofcontents ,于是软件自动根据你接下来出现的章节和子章节生成content


五、换行

前面介绍的是起段落,那么如何换行呢?
建立一个新文档,将以下内容复制进入文档中,保存:

\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} 

效果:
这里写图片描述

说明:
1.latex是不具有自动换行的功能的,即你在文本书写时换行并不会使其换行
2.一种换行的方法是:空一行
3.另一种换行的方法,用\\,但要注意:\\用在每一行的末尾,之后的内容便会出现在新的一行。
并且注意,用\\换的行是顶头的,没有缩进。


六、换页

用下面的代码即可

\newpage

七、使用公式

建立一个新文档,将以下内容复制进入文档中,保存:

\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} 

效果:
这里写图片描述

说明:
1.首先要加入这两句话

\usepackage{amsmath} 
  \usepackage{amssymb} 

2.两个$用来加斜体
3.特殊的阿拉伯字符有其固有的代码
4.表示分数的方法
\frac{a}{b}
5.表示指数的方法:a^b
6.下标的表示方法:a_b
7.偏导的表示方法:\frac{\partial y}{\partial t}
8.向量的表示方法:\vec{n}
9.字符加粗的表示方法:\mathbf{n}
10.头上加点的表示方法:\dot{F}
11.矩阵的表示方法:

\[ 
    \left[ 
      \begin{array}{lcr} 
        a1 & b22 & c333 \\ 
        d444 & e555555 & f6 
      \end{array} 
    \right] 
  \] 

12.单个方程的表示方法:

\begin{align} 
  a+b&=c\\ 
  d&=e+f+g 
\end{align} 

13方程组的表示方法:

\[ 
  \left\{ 
    \begin{aligned} 
      &a+b=c\\ 
      &d=e+f+g 
    \end{aligned} 
  \right. 
\] 

八、插入图片

建立一个新文档,将以下内容复制进入文档中,保存:

\documentclass{article} 
  \usepackage{graphicx} 
\begin{document} 
  \includegraphics[width=6.00in,height=5.00in]{CM2007.eps} 
\end{document} 

说明:
1.使用插入图片功能时要加入宏包:\usepackage{graphicx}
2.在\includegraphics[width=6.00in,height=5.00in]{CM2007.eps}
中可以设置图片的长和宽,另外最后面的是图片的名字,图片可以是jpg的,也可以是png,或者这里的eps。但是注意要把图片放在和这段代码一个文件夹下。

补充:这样插入的图片不一定是居中显示的。可以在\includegraphics[width=6.00in,height=5.00in]{CM2007.eps}
前加入一句:\centering 使其居中显示


九、关于宏包

\package{}就是在调用宏包,可以理解为工具箱。
每一个宏包里都定义了一些专门的命令,通过这些命令可以实现对于一类对象(如数学公式等)的统一排版(如字号字形),或用来实现一些功能(如插入图片或制作复杂表格)。
通常在\documentclass之后,在\begin{document}之前,将文章所需要涉及的宏包都罗列上。
对于新人而言比较常用的宏包有

编辑数学公式的宏包:\usepackage{amsmath}和 \usepackage{amssymb}
编辑数学定理和证明过程的宏包:\usepackage{amsthm}
插入图片的宏包:\usepackage{graphicx}
复杂表格的宏包:\usepackage{multirow}

差不多了,这五个宏包已经基本够用了。如果有其他的特殊需求,就通过google去寻找吧。


十、模板

模板就是在\documentclass{}后面的大括号里的内容。
在这一份教程中,我们使用的是LaTeX默认自带的模板article,以及中文模板ctexart。
这一片教程,我们定义了section,定义了paragraph,就是没有定义字体字号,因为字体字号这一部分通常来说是在模板中实现的。
一个模板可以规定,section这个层级都用什么字体什么字号怎么对齐,subsection这个层级用什么字体什么字号怎么对齐,paragraph又用什么字体什么字号怎么对齐。
当然模板里还可以包含一些自定义的口令,以及页眉页脚页边距一类的页面设置。


十一、插入表格

之间看我截取的其他博主的一片博客图片,就照着这个模板就行了:
http://blog.sina.com.cn/s/blog_57235cc70100jnpo.html

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值