基本语法
- 中文支持
\usepackage[UTF8]{ctex}
or \documentclass[UTF8]{ctexart} - 首行缩进
\usepackage{indentfirst}
or \setlength{\parindent}{2em} - begin{document} 正文 end{document}
- \documentclass{article} or book or report
- \usepackage{宏包1, 宏包2}
- 注释:% or \iffalse 注释内容 \fi
- 换行 \ 换段:空一行 换页 \newpage
- \section{一级标题} \subsection{二级标题} \subsubsection{二级标题}
高级
-
\usepackage[a4paper,left=10mm,right=10mm,top=15mm,bottom=15mm]{geometry}
-
\title{NSJim的文章} \author{NSJim} \date{\today}
-
\maketitle 显示标题等信息
-
摘要 begin{abstract} end{abstract}
-
引用:\begin{quote}和\end{quote}。
-
脚注:\footnote{脚注内容}
-
{\songti 宋体} {\heiti 黑体} {\fangsong 仿宋} {\kaishu 楷书}
-
{\bf 粗体} {\it 斜体}
-
导入宏包:\usepackage{url} 插入超链接:\url{www.baidu.com}
-
插入图片(\usepackage{graphicx})
\begin{figure}[htbp] % htbp代表图片插入位置的设置
\centering %图片居中
\includegraphics[width=6cm]{image.jpg}
%[]中为可选参数,可以设置图片的宽高;{}中为图片的相对位置
\caption{达尔文游戏} % 图片标题
\label{pic1} % 图片标签
\end{figure} -
插入表格
\begin{table}[htbp]
\centering
\caption{变量表}
% 创建table环境
\begin{tabular}{|cc|c|}
% 3个c代表3列都居中,也可以设置l或r,|代表竖线位置% 表格的输入
\hline % 一条水平线
x & y & z \
\hline
11 & 22 & 33 \
\hline\end{tabular}
\end{table} -
公式编号:\begin{equation} \end{equation}
-
代码块
\usepackage{listings}
\usepackage{xcolor}% 代码块高级设置
\lstset{
% basicstyle=\footnotesize, % 设置整体的字体大小
showstringspaces=false, % 不显示字符串中的空格
frame=single, % 设置代码块边框
numbers=left, % 在左侧显示行号
% numberstyle=\footnotesize\color{gray}, % 设置行号格式
numberstyle=\color{darkgray}, % 设置行号格式
backgroundcolor=\color{white}, % 设置背景颜色
keywordstyle=\color{blue}, % 设置关键字颜色
commentstyle=\it\color[RGB]{0,100,0}, % 设置代码注释的格式
stringstyle=\sl\color{red}, % 设置字符串格式
}\begin{lstlisting}[language=c]
#include <stdio.h>// main function
int main() {
printf(“Hello World!”);
return 0;
}
\end{lstlisting}
数学公式
- (行中公式): 数学公式 数学公式 数学公式;(独立公式): 数学公式 数学公式 数学公式【使用$$时,上方要空一行】
- {}表示整体;^_上下标;||绝对值
- \frac {分子} {分母}
- \sqrt [根指数] {被开方数} 注意:缺省根指数时为2
- \log_{对数底数}{表达式} \max_{下标表达式}{最值表达式}
- 方程组
{ a + b = 2 a − b = 4 \begin{cases} a+b=2 \\ a-b=4 \\ \end{cases} {a+b=2a−b=4 - 分段函数
y = { sin ( x ) x < 0 x 2 + 2 x + 4 0 ≤ x < 1 x 3 x ≥ 1 y = \begin{cases} \sin(x) & x<0 \\ x^2 + 2x +4 & 0 \leq x < 1 \\ x^3 & x \geq 1 \\ \end{cases} y=⎩ ⎨ ⎧sin(x)x2+2x+4x3x<00≤x<1x≥1 - \sum_{下标表达式}^{上标表达式}{累加表达式},\prod \bigcup \bigcap来分别输入累乘、并集和交集
- \vec{矢量}
- \lim_{变量 \to 表达式} 表达式 \int_积分下限^积分上限 {被积表达式}
- 矩阵
[ 1 x x 2 1 y y 2 1 z z 2 ] \left[ \begin{matrix} 1 & x & x^2 \\ 1 & y & y^2 \\ 1 & z & z^2 \\ \end{matrix} \right] 111xyzx2y2z2
细节
- 英文引号 ` thing ’
- '\ ’ ‘_’ 转义
- 空格 \quad \qquad