基本框架
\documentclass{article}
\begin{document}
Hello world!
\end{document}
基本语法
\documentclass{}规定了文档的类型,有article,book,letter等等类型。
在每一行的末尾加上%,然后就可以添加注释了,编译后注释的内容不会出现在文档中。如果文章内容中需要使用%的话,需要使用转义字符\%。
\documentclass{article}
\title{My first Latex document}
\author{ZZX}
\data{8/12/2021}
\begin{document}
\maketitle
\tableofcontents%目录信息
Hello world!
\end{document}
这样就可以将文章的标题、作者、日期等信息添加到文章中了,\maketitle这个控制序列可以将这些信息按照预定的格式打印出来。
添加章节
\section{}
\subsection{}
\subsubsection{}
添加段落
\paragraph{}
\subparagraph{}
\subsubparagraph{}
添加包
当需要使用非默认存在的包时,需要在导言区中添加,如
\usepackage{amsmath}
其中,论文编辑常用宏包如下:
// An highlighted block
\usepackage[comma,numbers,square,sort&compress]{natbib}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{indentfirst}
\setlength{\parindent}{2em}
\usepackage{caption}
\usepackage{float}
\usepackage[justification=centering]{caption}
\usepackage{color}
\usepackage{multirow}
字体设置
一般我们用fontspec包来设置字体
\usepackage{fontspec}
\setmainfont{Times New Roman}
字体大小
\tiny
\scriptsize
\footnotesize
\small
\normalsize
\large
\large
\LARGE
\huge
\Huge
$\LaTeX$安装
我所使用的是$\TeX$ Live2021 +vscode组合
Tex Live2021在清华镜像站安装,网址Index of /CTAN/systems/texlive/Images/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
下载完成后解压,打开文件夹中的install-tl-Windows.bat文件,点击左下角Advanced键,然后选择安装路径和组件即可开始安装。安装时间比较长,请耐心等待。
打开安装好的vscode,在插件中搜索LaTeX workshop并安装。
打开setting.json文件,并添加如下内容即可
"latex-workshop.latex.tools": [
{
"name":"xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
}, {
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}, {
"name": "latexmk",
"command": "latexmk",
"args": [
"-xelatex",
"-synctex=1",
"-interaction=nonstopmode",
"%DOCFILE%"
]
}
],
"latex-workshop.latex.recipes": [
{
"name": "latexmk",
"tools": [
"latexmk"
]
}
],
"latex-preview.command": "latexmk",