Latex常用命令汇总

        给最近自己学习Latex的各种命令做个笔记,方便后续编辑,不定期更新

一、环境配置相关

1.如何使用中文(以VsCode中为例)

        首先需要配置setting.json(可在插件-扩展文件中打开),将内容跟换为以下内容,即需要xelatex作为编译器。

{
    "latex-workshop.latex.tools": [
        {
            "name": "xelatex",
            "command": "xelatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOCFILE%"
            ]
        },
        {
            "name": "pdflatex",
            "command": "pdflatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOCFILE%"
            ]
        },
        {
            "name": "bibtex",
            "command": "bibtex",
            "args": [
                "%DOCFILE%"
            ]
        }
    ],
    "latex-workshop.latex.recipes": [
        {
            "name": "xelatex",
            "tools": [
                "xelatex"
            ],
        },
        {
            "name": "pdflatex",
            "tools": [
                "pdflatex"
            ]
        },
        {
            "name": "xe->bib->xe->xe",
            "tools": [
                "xelatex",
                "bibtex",
                "xelatex",
                "xelatex"
            ]
        },
        {
            "name": "pdf->bib->pdf->pdf",
            "tools": [
                "pdflatex",
                "bibtex",
                "pdflatex",
                "pdflatex"
            ]
        }
    ],
    "latex-workshop.view.pdf.viewer": "tab",
    "latex-workshop.latex.autoBuild.run": "onFileChange",
    "latex-workshop.message.error.show": false,
    "latex-workshop.message.warning.show": false,
}

        而后在Tex文件中调用即可使用中文:

\usepackage[UTF8]{ctex}

二、文章内容相关

 模板

\documentclass{article}
% Useful packages
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[UTF8]{ctex}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}

\title{CDC-0911}
\author{Zhou}

\begin{document}
\maketitle

\section{Matlab Function的部署}

\end{document}

1.封面格式

       在\begin{document}前需要定义

\title{some words}
\author{You}
\date{\today}

        而后在{document}中

\maketitle

2.章节内容

\section{Some examples to get started}

\subsection{How to create Sections and Subsections}

3.插入图片

        需要实现导入包

\usepackage{graphicx}

        后续document中即可通过以下实现图片插入 

\begin{figure}[htbp]
    \centering
    \includegraphics[height=4.5cm,width=9.5cm]{image/Abstract_Submission.png}
    \caption{}
\end{figure}

        可以通过命令使得图片放缩

        \includegraphics[scale=0.8]{image/coordinate.png}

三、公式编辑相关

1.段落内直接添加公式

        需要通过(...中写入符合Latex语法格式表示的数学表达式,如字母、公式等)

$ ... $

        举例如下 

\LaTeX{} is great at typesetting mathematics. Let $X_1, X_2, \ldots, X_n$ be a sequence of independent and identically distributed random variables with $\text{E}[X_i] = \mu$ and $\text{Var}[X_i] = \sigma^2 < \infty$, and let
\[S_n = \frac{X_1 + X_2 + \cdots + X_n}{n}
      = \frac{1}{n}\sum_{i}^{n} X_i\]
denote their mean. Then as $n$ approaches infinity, the random variables $\sqrt{n}(S_n - \mu)$ converge in distribution to a normal $\mathcal{N}(0, \sigma^2)$.

2.独立公式

        需要通过begin,另起一个新环境,表现效果为换行居中显示公式

\begin{equation}

    E=mc^2

\end{equation}

        存在大括号括起多行公式的情况

    \begin{equation}
        \begin{cases}
            \dot{X} = \dot{x} \cdot cos(\varphi)-\dot{y} \cdot sin(\varphi ) \\
            \dot{Y} = \dot{x} \cdot sin(\varphi)+\dot{y} \cdot cos(\varphi ) 
        \end{cases}
    \end{equation}

       给公式打上标签后,后续即可通过\ref命令引用(但注意\ref需要连续编译两次才可以正确显示,不然就会显示??)

    \begin{equation}
        \begin{cases}
            \dot{s\_t\_x} = \dot{v\_t\_x} \cdot cos(\varphi)-\dot{v\_t\_y} \cdot sin(\varphi ) \\
            \dot{s\_t\_y} = \dot{v\_t\_x} \cdot sin(\varphi)+\dot{v\_t\_y} \cdot cos(\varphi ) 
            \label{equation2}
        \end{cases}
    \end{equation}

3.表格

        表格具有多种实现方式

\begin{enumerate}
\item Like this,
\item and like this.
\end{enumerate}
\dots or bullet points \dots
\begin{itemize}
\item Like this,
\item and like this.
\end{itemize}

四、报错

4.1 IEEE Latex模板编译报错

Font shape `TU/ptm/b/n' undefined
(Font)	using `TU/ptm/bx/n' instead.
LaTeX

解决方案:选择pdflatex编译器进行编译即可。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值