Latex 简单安装和使用

1、texlive 下载

可以去官网下载,也可在清华源镜像下载
Latex 简单安装和使用_第1张图片
下载框框里面的iso文件

2、安装

点击下面的安装指令,根据提示选择自己的安装路径,点击安装即可
Latex 简单安装和使用_第2张图片
经过一个较长的时间等待,安装完毕,到cmd里面敲指令:

tex -version
# 能够正常显示下面的版本号,就安装成功了
# TeX 3.14159265 (TeX Live 2020/W32TeX)

3、安装编辑器 Texstudio

下载路径,下载后,选择自己的安装路径安装即可。
打开的界面目录如下,选择Options有很多可以配置的东西
在这里插入图片描述
(1)设置语言为中文
Options -> Configure Texstudio-> General -> Language: 选择 zh_CN,点击确认即可切换成中文。
Latex 简单安装和使用_第3张图片
(2) 显示行号
同样进入刚刚的配置界面,选择左下角的显示高级选项,点击高级编辑器,把显示行号的这一栏选中: 所有行号。
Latex 简单安装和使用_第4张图片

4、.tex文件编写与运行

1、新建第一个.tex 文件

\documentclass{article}

\begin{document}
	hello jun !
\end{document}

保存好后,点击编译查看键,就可以显示内容在右边,默认是pdf格式。
Latex 简单安装和使用_第5张图片
基本语法说明:
新建一个文档时,首先必须加入第一行,表示编写的是文章
主题内容的开始,写在 \begin{document} \end{document} 这一对标签里面,这一点很像html。
% 表示写注释

2、复杂案例

% This is a small sample LaTeX input file (Version of 10 April 1994)
%
% Use this file as a model for making your own LaTeX input file.
% Everything to the right of a  %  is a remark to you and is ignored by LaTeX.
 
% The Local Guide tells how to run LaTeX.
 
% WARNING!  Do not type any of the following 10 characters except as directed:
%                &   $   #   %   _   {   }   ^   ~   \   
 
\documentclass{article}        % Your input file must contain these two lines 

\author{solicucu}
\title{Learnig Tex}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}               % plus the \end{document} command at the end.
\maketitle       % make the title
\tableofcontents % add the content
 
\section{Simple Text}          % This command makes a section title.
 
Words are separated by one or more spaces.  Paragraphs are separated by
one or more blank lines.  The output is not affected by adding extra
spaces or extra blank lines to the input file.
 
Double quotes are typed like this: ``quoted text''.
Single quotes are typed like this: `single-quoted text'.
Long dashes are typed as three dash characters---like this.
Emphasized text is typed like this: \emph{this is emphasized}.
Bold       text is typed like this: \textbf{this is bold}.
\subsection{A Warning or Two}  % This command makes a subsection title.
If you get too much space after a mid-sentence period---abbreviations
like etc.\ are the common culprits)---then type a backslash followed by
a space after the period, as in this sentence.
Remember, don't type the 10 special characters (such as dollar sign and
backslash) except as directed!  The following seven are printed by
typing a backslash in front of them:  \$  \&  \#  \%  \_  \{  and  \}.  
The manual tells how to make other symbols.

% section2 show the subsection and paragraph
\section{Hello China} China is in East Asia.
	\subsection{Hello Beijing} Beijing is the capital of China.
		\subsubsection{Hello Dongcheng District}
		\paragraph{Tian'anmen Square}is in the center of Beijing
			\subparagraph{Chairman Mao} is in the center of Tian'anmen Square
	\subsection{Hello Huazhou}
	\paragraph{Hunan University} is a beautiful university.
	% test the change lines, leaves a blank line just ok
	
	HNU is 
	
	located at 
	
	changsha At \\ Hunna province \\
	
% section3 show the formula
\section{Math formula}
	The Newton's second law is F=ma.
	
	The Newton's second law is $F=ma$.
	
	The Newton's second law is
	$$F=ma$$
	
	The Newton's second law is
	\[F=ma\]
	
	Greek Letters $\eta$ and $\mu$
	
	Fraction $\frac{a}{b}$
	
	Power $a^b$
	
	Subscript $a_b$
	
	Derivate $\frac{\partial y}{\partial t} $
	
	Vector $\vec{n}$
	
	Bold $\mathbf{n}$
	
	To time differential $\dot{F}$
	
	Matrix (lcr here means left, center or right for each column)
	\[
	\left[
	\begin{array}{lcr}
	a1 & b22 & c333 \\
	d444 & e555555 & f6
	\end{array}
	\right]
	\]
	
	Equations(here \& is the symbol for aligning different rows)
	\begin{align}
	a+b&=c\\
	d&=e+f+g
	\end{align}
	
	\[
	\left\{
	\begin{aligned}
	&a+b=c\\
	&d=e+f+g
	\end{aligned}
	\right. % denote no need } ba 
	\]	
	
% section 4 show the table
\section{Table}
	\begin{tabular}{|c|c|}
		a & b \\
		c & d\\
	\end{tabular}

	next line
	
	\begin{tabular}{|c|c|}
		\hline
		a & b \\
		\hline
		c & d\\
		\hline
	\end{tabular}
	
	\begin{center}
		\begin{tabular}{|c|c|}
			\hline
			a & b \\ \hline
			c & d\\
			\hline
		\end{tabular}
	\end{center}
\end{document}                 % The input file ends with this command.

Latex 简单安装和使用_第6张图片
Latex 简单安装和使用_第7张图片
Latex 简单安装和使用_第8张图片
Latex 简单安装和使用_第9张图片

3、公式案例

% write my paper formula
\documentclass{article}
\author{solicucu}
\title{formula}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}
	\maketitle
	\section{solicucu}
		\subsection{mixops}
		% use equation will auto-add the order
		\begin{equation}
			O(x) = \sum_{i=1}^7\dfrac{\exp(\alpha_{i})}{\sum_{j=1}^7\exp(\alpha_{j})}o_{i}(x)
		\end{equation}
		
		\subsection{update $\alpha$}
		\begin{equation}
			\alpha^* = \alpha - \eta_{\alpha} * \bigtriangledown\alpha L_{val}(w^*, \alpha)
		\end{equation}
		
		\subsection{update $w$}
		\begin{equation}
			w^* = w - \eta_{w} * \bigtriangledown w L_{train}(w, \alpha^*)
		\end{equation}
		
		\subsection{Loss}
		\begin{equation}
			Loss = GL_{id1} + GL_{tri} + GL_{id2} + LL_{tri}
		\end{equation}
		
		\subsection{ID Loss}
		\begin{equation}
			Loss(f) = \sum_{i=1}^{c}-q_{i}\log(p_{i}) \qquad q_{i} = 1 \quad if \quad y == i \quad else \quad  0
		\end{equation}
		
		\subsection{batch loss}
		\begin{equation}
			Loss(F) = \sum_{i=1}^{N}L(f_{i})
		\end{equation}
		
		\subsection{triplet loss}
		\begin{equation}
			dist(x^a, x^n) - dist(x^a, x^p) -m >= 0
		\end{equation}
		
		\subsection{triplet define}
		\begin{equation}
			L_{tri} = \sum_{i=1}^{N}[max(dist(x_{i}^a, x^p)) - min(dist(x_{i}^a, x^n)) + m]_{+}
		\end{equation}
		
		\subsection{AP}
		\begin{equation}
			AP(q) = \frac{1}{M}\sum_{i=1}^{M}\frac{i}{k_{i}}
		\end{equation}
		
		\subsection{mAP}
		\begin{equation}
			mAP = \frac{1}{N}\sum_{i=1}^{N}AP(q_{i})
		\end{equation}
		
		\subsection{warmup}
		\begin{equation}
			lr(t) = \left\lbrace 
			\begin{aligned}
				&2.5 \times 10^{-3}  \qquad &if \quad t<=10 \\
				&1.2 \times 10^{-2} \times (\cos(\frac{t-10}{150}\pi)+1) + 0.001 &otherwise
			\end{aligned}
			\right.
		\end{equation}
		
		\subsection{label smooth}
		\begin{equation}
			q_{i} = \left\lbrace 
			\begin{aligned}
				&1-\frac{N-1}{N}\epsilon \qquad &if \quad i == y, \\  
				&\frac{1}{N} \epsilon  &otherwise
			\end{aligned}
			\right.
		\end{equation}
\end{document}

Latex 简单安装和使用_第10张图片
Latex 简单安装和使用_第11张图片
Latex 简单安装和使用_第12张图片
1.4 常用标签总结

\author{solicucu} # 定义作者名字
\title{formula} # 定义文章题目, 然后在主提里面要加上 \maketitle
\usepackage{amsmath} # 写数学公式需要引用的包
\usepackage{amssymb} # 同上
\section{name} # 创建章节
\subsectioin{name} # 创建子章节
$ fomula $表示在行内嵌入公式
$$ 表示公式独立占一行 $ $
\\ 表示换行
a_{i}^j: 下标写在大括号,上标在^ 之后,如果有多个字母,可以用{} 括起来
\sum_{i=1}^{N} 累加公式,跟上下标差不多
\frac{分子}{分母} # 分式
\quad # 单个空格, \qquad # 两个空格
左大括号,实现可以写多行内容,&起到对齐的作用,但是要写在 aligned 环境里面。

\left\lbrace
	\begin{aligned}
		&  line1
		&  line2 
	\end{aligned} 
\right.

关于给公式标上序号

\begin{equation}
\end{equation}
# 这一对标签可以写公式,而且从默认自动从上往下,给公式加上序号在末尾

其实在左侧有很多常用的符号,直接点击使用即可
Latex 简单安装和使用_第13张图片

你可能感兴趣的:(学习资料,latex)