Latex入门

基本语法

  • 中文支持
    \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=2ab=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<00x<1x1
  • \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
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值