Latex学习笔记

Latex文档分为导言区与正文区

在导言区可以用\documentclass{class}引入一个文档类,除了文档类还可以有book类report类,letter类

在正文区用\begin和\end输入一个环境,在中间的位置content可以书写内容

导言区主要进行全局设置,例如可以用\title来设置文章标题,\author来设置文章作者,\data来设置书写时间,\date{\today}表示今天,为了能显示这些信息,需要在正文区加上一个\maketitle(注意当documentclass=letter时,不能使用)

Latex中用$包围的一般称为数学模式,之外的一般称为文本模式,例如

\begin{document}
    \maketitle
    Hello World!
    Let $f(x)$ be defined by the formula $f(x)=3x^2+x-1$.
\end{document}

显示如下:

Latex学习笔记

若想将Hello World!与后面的分成两行只需要加一个空行

\begin{document}
    \maketitle
    Hello World!
    
    Let $f(x)$ be defined by the formula $f(x)=3x^2+x-1$.
\end{document}

若将公式用$$来包围,则公式会另起一行进行展示:例如$$f(x) = x^2+4$$,在Latex中单$表示行内公式双$表示行间公式。

\begin{document}
    \maketitle
    Hello World!
    
    Let $f(x)$ be defined by the formula. $$f(x)=3x^2+x-1$$Which is very NB.
\end{document}
显示如下:

Latex学习笔记

有的时候需要在导言区用\newcommand来定义新的命令,Latex处理中文时,需要在导言区加\usepackage{ctex}引入ctex宏包,同时需要保证文件编码时UTF-8

在一个环境中还可以创建新的环境,equation环境可以输出带编号的公式,不需要用$包围,例如

\begin{equation}
        g(x) = a+b
    \end{equation}

输出如下:

Latex学习笔记