【参考视频:点这里】
目录
一、texlive2018环境安装
关掉杀毒软件,1以管理员模式运行下面这个.bat文件
漫长的安装过程(我装在了SSD,大概用了40多分钟)
查看tex版本(TeX:一种宏语言。)
查看latex版本(LaTex: Tex中的一个宏集合)
查看xelatex版本(XeLaTeX是新的Unicode版本,内建支持Unicode(UTF-8),自然也包括汉字在内,而且可以调用操作系统的truetype字体。如果你的文档有汉字,那么推荐用XeLaTeX。缺点是不支持某一些宏包。)
二、 texstudio编辑器安装
只装了texlive的话不方便操作,于是装个IDE,傻瓜式安装。
Option--Configure--General--Language修改语言
三、基础快速入门
% 导言区(global settings)
\documentclass{article} % book,report,letter
\title{A Super Model Base On Me}
\author{Mu Yao}
\date{\today}
% 文稿区(What to show)
\begin{document}
\maketitle % 输出上面定义的title author date
Hello world!
Let $f(x)$ be defined by the formula $f(x)=3x^2+x-1$.
And let $g(x)$ be defined by the formula $$g(x)=2x^5+x$$ which is a good formula.
\end{document}
一堆红线怎么办(选项--设置--语言检查--设置默认字典为en_US)!
更多帮助文档:cmd中输入texdoc lshort-zh,中文相关的是texdoc ctex
四、中文处理
更多帮助文档:cmd中输入texdoc ctex
% 导言区(global settings)
\documentclass{article} % book,report,letter
% 处理中文的两种方式
%\documentclass{ctexart} % 第一种
\usepackage{ctex} % 第二种 引入ctex宏包 处理中文
\newcommand\mydegree{^\circ}
\title{\heiti 基于SuperModel的深度学习方法} % 黑体
\author{\kaishu 木尧大兄弟} % 楷书
\date{\today}
% 文稿区(What to show)
\begin{document}
\maketitle % 输出上面定义的title author date
Hello world!
Let $f(x)$ be defined by the formula $f(x)=3x^2+x-1$.
And let $g(x)$ be defined by the formula
\begin{equation} % 带编号的行间公式
g(x)=2x^5+x % 公式前后不用$了
\end{equation}
which is a good formula.
这真是个$90\mydegree$大反转。 % 引入上面自定义的mydegree
\end{document}
五、字体设置
% 字体族
\textrm{Roman Family} % 罗马字体命令
{\rmfamily Roman} {\sffamily Family} % 字体声明 {}限定范围
\textsf{San Serif Family} % 无衬线字体
\sffamily{San Serif Family} % 字体声明
\texttt{Typewriter Family} % 打字机字体
\ttfamily{Typewriter Family} % 字体声明
% 字体系列(粗细 宽度)
\textmd{Medium Series}
{\mdseries Medium Series}
\textbf{Boldface Series}
{\bfseries Boldface Series}
% 字体形状(直立 斜体 伪斜体 小型大写)
\textup{Upright}
{\upshape Upright}
\textit{Italic Shape}
{\itshape {}Italic Shape}
\textsl{Slanted Shape}
{\slshape Slanted Shape}
\textsc{Small Caps Shape}
{\scshape Small Caps Shape}
% 中文字体设置
{\songti 宋体} \quad % one char blank
{\heiti 黑体}
{\fangsong 仿宋}
{\kaishu 楷书}
中文字体的\textbf{粗体}和\textit{斜体}
% 中文字体的\bf{粗体}和\it{斜体}
% font size
{\tiny Hello world}\\
{\scriptsize Hello world}\\
{\footnotesize Hello world}\\
{\small Hello world}\\
{\normalsize Hello world}\\
{\large Hello world}\\
{\Large Hello world}\\
{\LARGE Hello world}\\
{\huge Hello world}\\
{\Huge Hello world}\\
% 中文字号设置
\zihao{-0} 哈喽 沃德!% -0是小初 5是五号
自定义字体:
\newcommand{\myfont}{\textit{\textbf{\textsf{Fancy Text}}}}
正文区: \myfont
效果:
六、提纲和文档结构
% 导言区
% \documentclass{article} % \subsubsection有作用
% \documentclass{ctexart} % 一级标题居中排版 % \subsubsection有作用
\documentclass{ctexbook} % \subsubsection无作用
\usepackage{ctex}
% ==========设置标题格式============
\ctexset{
section = {
format+ = \zihao{-4} \heiti \raggedright,
name = {,、},
number = \chinese{section},
beforeskip = 1.0ex plus 0.2ex minus .2ex,
afterskip = 1.0ex plus 0.2ex minus .2ex,
aftername = \hspace{0pt}
},
subsection = {
format+ = \zihao{5} \heiti \raggedright,
number = \arabic{subsection},
beforeskip = 1.0ex plus 0.2ex minus .2ex,
afterskip = 1.0ex plus 0.2ex minus .2ex,
aftername = \hspace{0pt}
}
}
% 正文区
\begin{document}
\tableofcontents % 生成目录
\chapter{这里是第一章} % 章节
\section{引言} % 构建小节
摘要又称概要、内容提要。摘要是以提供文献内容梗概为目的,不加评论和补充解释,简明、确切地记述文献重要内容的短文。其基本要素包括研究目的、方法、结果和结论。
% \\换行 无缩进
% \par 产生新的段落 有缩进
摘要又称概要、内容提要。\\ 摘要是以提供文献内容梗概为目的,不加评论和补充解释,简明、确切地记述文献重要内容的短文。\par 其基本要素包括研究目的、方法、结果和结论。
\section{实验方法} % 构建小节
\section{实验结果} % 构建小节
\subsection{数据} % 构建子小节
\subsubsection{实验条件} % 构建子子小节
\subsubsection{实验过程} % 构建子子小节
\subsection{图表} % 构建子小节
\subsection{分析} % 构建子小节
\chapter{这里是第二章} % 章节
\section{结论} % 构建小节
\section{致谢} % 构建小节
\end{document}
七、特殊字符
% 导言区
\documentclass{article}
\usepackage{ctex}
\usepackage{xltxtra} % 为了产生XeLaTex的logo
\usepackage{texnames} % some logo
\usepackage{mflogo} % some logo
% 正文区
\begin{document}
\section{空白符号}
a\quad b % 1em
a\qquad b % 2em
a\,b % 1/6em
a\thinspace b % 1/6em
a\enspace b % 0.5em
a\ b % 空格
a~b % 硬空格(不能分割的空格)
a\kern 1pc b % 1pc=12pt=4.218mm
a\kern -1em b
a\hskip 1em b
a\hspace{35pt}b
a\hphantom{xyz}b % 根据占位符宽度产生空格
a\hfill b % 产生弹性长度的空白 撑满空间
\section{\LaTeX 控制符}
\#
\$
\%
\&
\{
\}
\~{}
\_{}
\^{}
\textbackslash % 反斜杠
\section{排版符号}
\S
\P
\dag
\ddag
\copyright
\pounds
\section{\TeX 标志符号}
\TeX{} % {}多了个空格
\LaTeX{}
\LaTeXe{}
% xltxtra宏包提供
\XeLaTeX
% texnames宏包提供
\AmSTeX{}
\AmS-\LaTeX{}
\BibTeX{}
\LuaTeX{}
% mflogo宏包提供
\METAFONT{}
\MF{}
\MP{}
\section{引号}
` % 数字键1的撇 左单引号
' % 单引号代表 右单引号
`` % 左双引号
'' % 右双引号
``你好'' % example
\section{连字符}
-
--
---
\section{非英文字符}
\oe
\OE
\ae
\AE
\aa
\AA
\o
\O
\l
\L
\ss
\SS
!`
?`
\section{重音符号(以o为例)}
\`o
\'o
\^o
\''o
\~o
\=o
\.o
\u{o}
\v{o}
\H{o}
\r{o}
\t{o}
\b{o}
\c{o}
\d{o}
八、插入图片
% 导言区
\documentclass{ctexart}
% 导言区: \usepackage{graphicx}
% 语 法: \includegraphics[<opt>]{<filename>}
% 格 式: EPS,PDF,PNG,JPEG,BMP
\usepackage{graphicx}
\graphicspath{{figures/},{pics/}} % file path: ./figures {}分组
% 正文区
\begin{document}
\LaTeX{}中的插图示例:
% 原图
\includegraphics{test} % \includegraphics[可选参数]{文件名}
\includegraphics{logo} % \includegraphics[可选参数]{文件名}
% 指定缩放
\includegraphics[scale=0.3]{test}
\includegraphics[scale=0.03]{logo}
% 指定高度 宽度自动调整
\includegraphics[height=2cm]{test}
\includegraphics[height=2cm]{logo}
% 指定高度比例 宽度自动调整
\includegraphics[height=0.01\textheight]{test}
\includegraphics[height=0.01\textheight]{logo}
% 指定宽度 高度自动调整
\includegraphics[width=2cm]{test}
\includegraphics[width=2cm]{logo}
% 指定宽度比例 高度自动调整
\includegraphics[width=0.01\textwidth]{test}
\includegraphics[width=0.01\textwidth]{logo}
% 同时指定旋转角度、宽度
\includegraphics[angle=-45,width=0.2\textwidth]{test}
\includegraphics[angle=-45,width=0.2\textwidth]{logo}
\end{document}
九、插入表格
% 导言区
\documentclass{ctexart}
% 正文区
\begin{document}
\begin{tabular}{l||c|p{5cm}|c|r} % 生成表格 左 中 右 对齐 p指定宽度
% | 产生表格竖线
\hline % 产生表格横线
\hline % 产生表格横线
id & title & abstract & category & info\\
\hline % 产生表格横线
00001 & t001 & a001 & c001 & i001\\
0002 & t002 & a002 & c002 & i000002\\
003 & t003 & a003 & c003 & i003\\
\hline % 产生表格横线
\hline % 产生表格横线
\end{tabular}
\end{document}
十、图片和表格的浮动体
% 导言区
\documentclass{ctexart}
\usepackage{graphicx}
\graphicspath{{figures/},{pics/}} % file path: ./figures {}分组
% 常用选项[htbp]是浮动格式:
%『h』当前位置。将图形放置在正文文本中给出该图形环境的地方。本页所剩页面不够,参数不起作用。
%『t』顶部。将图形放置在页面的顶部。
%『b』底部。将图形放置在页面的底部。
%『p』浮动页。将图形放置在一只允许有浮动对象的页面上。
% 正文区
\begin{document}
\LaTeX{}中的插图如图\ref{fig-jun} 所示:
\begin{figure}[htbp] % 图片的浮动体环境
\centering % 居中
\includegraphics[height=5cm]{test}
\caption{\TeX 系统的军装} \label{fig-jun} % 参考引用
\end{figure}
\LaTeX{}中的第二个插图如图\ref{fig-jun2} 所示:
\begin{figure}[htbp] % 图片的浮动体环境
\centering % 居中
\includegraphics[height=1cm]{test}
\caption{\TeX 系统的第二个小军装} \label{fig-jun2} % 参考引用
\end{figure}
\LaTeX{}中的表格如表\ref{tab-fake}所示:
\begin{table}[htbp]
\centering % 居中
\caption{生成信息统计表} \label{tab-fake}
\begin{tabular}{l||c|p{5cm}|c|r} % 生成表格 左 中 右 对齐 p指定宽度
% | 产生表格竖线
\hline % 产生表格横线
\hline % 产生表格横线
id & title & abstract & category & info\\
\hline % 产生表格横线
00001 & t001 & a001 & c001 & i001\\
0002 & t002 & a002 & c002 & i000002\\
003 & t003 & a003 & c003 & i003\\
\hline % 产生表格横线
\hline % 产生表格横线
\end{tabular}
\end{table}
\end{document}
十一、数学公式
% 导言区
\documentclass{article}
\usepackage{ctex}
\usepackage{amsmath}
% 正文区
\begin{document}
\section{简介}
\LaTeX{}分为文本模式和数学模式。
\section{行内公式}
\subsection{美元符号}
交换律是$ a+b=b+a $。
\subsection{小括号}
交换律是\(a+b=b+a\)。
\subsection{math环境}
交换律是\begin{math} a+b=b+a \end{math}。
\section{上下标}
\subsection{上标}
$ 3x^{20 + y} - x + 2 = 0 $
\subsection{下标}
$ x_{i_{22}} + y_{j_{33}} = 0 $
\section{希腊字母}
$\alpha$
$\beta$
$\gamma$
$\epsilon$
$\pi$
$\omega$
$\Gamma$
$\Delta$
$\Theta$
$\Pi$
$\Omega$
$ \alpha + \beta = \gamma $
\section{数学函数}
$\log$
$\sin$
$\cos$
$\arcsin$
$\arccos$
$\ln$
$ \sin^2 x + \cos^2 x = 1 $
$ y = \sin^{-1} x + \log_2 x + \ln x $
$ \sqrt{x^2 + \sqrt{2} } = \sqrt[4]{x} $ % [4]根数
\section{分式}
$ 3/4 + \frac{1}{\sqrt{16}} = 1 $
\section{行间公式}
\subsection{双美元符号}
交换律是$$ a+b=b+a $$ 如 $$ 1+2=2+1 $$
\subsection{中括号}
交换律是\[ a+b=b+a \] 如 \[ 1+2=2+1 \]
\subsection{displaymath环境}
交换律是
\begin{displaymath}
a+b=b+a
\end{displaymath}
如
\begin{displaymath}
1+2=2+1
\end{displaymath}
\subsection{自动编号公式equation环境}
传说中的交换律就是式\ref{eq_test1}所描述的那样。
\begin{equation}
a+b=b+a \label{eq_test1}
\end{equation}
传说中的错误交换律就是小节\ref{eq_test2}所描述的那样
\begin{equation*}
a-b=b-a \label{eq_test2}
\end{equation*}
\end{document}
矩阵排版
引入宏包 \usepackage{amsmath}
\section{矩阵排版}
\subsection{普通矩阵}
\[
% 只有数字的矩阵
\begin{matrix}
0 & 1\\
1 & 0
\end{matrix} \qquad
% 带小括号的矩阵
\begin{pmatrix}
0 & -k\\
1 & 0
\end{pmatrix} \qquad
% 带中括号的矩阵
\begin{bmatrix}
0 & -k\\
1 & 0
\end{bmatrix} \qquad
% 带大花括号的矩阵
\begin{Bmatrix}
0 & -k\\
1 & 0
\end{Bmatrix} \qquad
% 带单竖线的矩阵
\begin{vmatrix}
0 & -k\\
1 & 0
\end{vmatrix} \qquad
% 带双竖线的矩阵
\begin{Vmatrix}
0 & -k\\
1 & 0
\end{Vmatrix} \qquad
\]
\subsection{省略号}
\[
A = \begin{bmatrix}
a_{11}^2 & a_{12}^2 & \dots & a_{1n}^2 \\
0 & a_{22}^2 & \dots & a_{2n}^2 \\
0 & \adots & \ddots & \vdots \\
0 & 0 & 0 & a_{nn}^2
\end{bmatrix}_{n \times n}
\]
\subsection{分块矩阵与嵌套}
\[
\begin{pmatrix}
% \text临时切换到文本模式
\begin{matrix} 1&0\\0&1 \end{matrix} & \text{\Large 0} \\
\text{\Large 0} & \begin{matrix} 1&0\\0&-1 \end{matrix}
\end{pmatrix}
\]
\subsection{三角矩阵}
% \multicolumn合并多列
% \raisebox调整高度
\[
\begin{pmatrix}
a_{11} & a_{12} & \cdots & a_{1n} \\
& a_{22} & \cdots & a_{2n} \\
& & \ddots & \vdots \\
\multicolumn{2}{c}{\raisebox{1.3ex}[0pt]{\Huge 0}}
& & a_{nn}
\end{pmatrix}
\]
\subsection{跨列省略号}
\[
\begin{pmatrix}
1 & \frac{1}{2} & \dots & \frac{1}{n} \\
\hdotsfor{4} \\
m & \frac{m}{2} & \dots & \frac{m}{n} \\
\end{pmatrix}
\]
\subsection{行内小矩阵}
复数$ z=(x,y) $可以用矩阵
\begin{math}
\left(
\begin{smallmatrix}
x&-y\\y&x
\end{smallmatrix}
\right)
\end{math}来表示。
\subsection{array环境(类似于表格tabular)}
\[
\begin{array}{r|r}
\frac{1}{2} & 0 \\
\hline
0 & -\frac{a}{b}c \\
\end{array}
\]
多行公式排版
引入宏包 amsmath amssymb
\usepackage{amsmath}
\usepackage{amssymb}
\section{多行公式排版}
\subsection{gather环境}
% gather带编号 \notag阻止编号
\begin{gather}
a+b=b+a \notag \\
a-b\not=b-a
\end{gather}
% gather*不带编号
\begin{gather*}
a\times b=b\times a\\
a-b\not=b-a
\end{gather*}
\subsection{align环境}
% 用&指定对齐的符号
% 带编号
\begin{align}
x &= t + \cos t + 1 \\
y &= 2\sin t
\end{align}
% 不带编号
\begin{align*}
x &= t & x &= \cos t & x &=t \\
y &= 2t & y &= \sin (t+1) & y &=\sin t
\end{align*}
\subsection{split环境}
% 一个公式多行连等
\begin{equation}
\begin{split}
\cos 2x &= \cos^2x-\sin^2x \\
&= 2\cos^2x-1
\end{split}
\end{equation}
\subsection{cases环境}
% 条件判断类的公式 \text{}在数学公式中处理中文
\begin{equation}
D(x) = \begin{cases}
1, &\text{如果}x \in \mathbb{Q};\\
0, &\text{如果}x \in \mathbb{R} \setminus \mathbb{Q};
\end{cases}
\end{equation}
十二、参考文献
1.参考文献之 “thebibliography环境”
%导言区
\documentclass{ctexart}
%正文区
\begin{document}
% 一次管理,一次使用
% 参考文献格式:
% \begin{thebibliography}{编号样本}
% \bibitem[记号]{引用标志}文献条目1
% \bibitem[记号]{引用标志}文献条目2
% ...
% \end{thebibliography}
% 其中文献条目包括:作者,题出版社,年代,版本,页码等。
% 引用的时候可以采用:\cite{引用标志1,引用标志2...}
深度学习以被\cite{article1}用在了宇宙进化的研究之中,Vae的著作\cite{latexMath}对其有很大启发。
\begin{thebibliography}{99}
\bibitem{article1}木尧工作室.\emph{基于深度学习的宇宙进化论}[J]. 计算机科学. 2019(05)
\bibitem{book1}William, \emph{Hello World}, 2019
\bibitem{latexGuide}Jay Chou, \emph{Guide to \LaTeX}, $4^{th}$Edition.At \texttt{www.baidu.com}
\bibitem{latexMath} Vae, \emph{Math Into \LaTeX}, 3 edition (June 22, 2019).
\end{thebibliography}
\end{document}
2.参考文献之 “bib文件”(BibTeX)
新建一个bib文件
tex文件中第一次编译生成这个文件
添加引用,再次编译并运行
%导言区
\documentclass{ctexart}
\usepackage{ctex}
\bibliographystyle{plain} % 参考文献排版样式
%\bibliographystyle{alpha} % 参考文献排版样式
%正文区
\begin{document}
这是参考文献\cite{my_cite},
这是另一个参考文献\cite{Perlmutter2005Deep}
% 排版所有参考文献 否则只排版引用到的
\nocite{*}
% 不同bib文件用逗号分隔
\bibliography{my_conferences,another_conf}
\end{document}
知网导出Bib的一个火狐插件
清理编译过程文件
在用latex导入参考文献时,有时会出现错误,原因在于参考文献中出现了&,这是我们在前面加上\就可以了。即
& -> \&
alpha样式:
\bibliographystyle{alpha} % 参考文献排版样式
plainnat样式:
\usepackage{natbib} % 使用更多样式
\bibliographystyle{plainnat} % 参考文献排版样式
引用格式:citet和citep
3.参考文献之Biber(BibLaTeX)
%导言区
\documentclass{ctexart}
\usepackage{ctex}
\usepackage[style=numeric,backend=biber]{biblatex}
\addbibresource{my_conferences.bib} % 不可省略.bib
\addbibresource{another_conf.bib} % 不可省略.bib
%正文区
\begin{document}
% 一次管理 多次引用
无格式化引用\cite{Breit2004Deep}
带方括号的引用\parencite{Perlmutter2005Deep}
上标引用\supercite{Kupsch2006Pallidal}
% 列出参考文献
\nocite{*}
\printbibliography[title = {参考文献}]
\end{document}
%导言区
\documentclass{ctexart}
\usepackage{ctex}
% c-中 e-英 n-姓名 t-标题 y-年份
\usepackage[style=caspervector,
backend=biber,
utf8,
sorting = nty]{biblatex}
\addbibresource{my_conferences.bib} % 不可省略.bib
%正文区
\begin{document}
% 一次管理 多次引用
无格式化引用\cite{Breit2004Deep}
带方括号的引用\parencite{Perlmutter2005Deep}
上标引用\supercite{Kupsch2006Pallidal}
% 列出参考文献
\nocite{*}
\printbibliography[title = {参考文献}]
\end{document}
十三、 自定义命令和环境
%导言区
\documentclass{ctexart}
\usepackage{ctex}
% 简单字符串替换
\newcommand\PRC{People's Republic of \emph{China}}
% 使用参数1,2...9
\newcommand\loves[2]{#1 喜欢 #2} % 小明喜欢小兰
\newcommand\hateby[2]{#2 不受 #1 喜欢} % 小明不受小兰喜欢
% 为第一个参数指定默认值
\newcommand\looklike[3][长得像]{#2#1#3}
% 重定义已有的命令
\renewcommand\abstractname{这里是摘要名}
% 定义新环境
\newenvironment{myabstract}[1][新时代,新摘要]
{
% 环境前定义
\small % font-size
\begin{center}\bfseries #1\end{center}
\begin{quotation}
}
% 环境后定义
{
\end{quotation}
}
%正文区
\begin{document}
% 简单字符串替换
\PRC
% 使用参数1,2...9
\loves{鱼儿}{水},就像\loves{我}{你}
\hateby{喵星人}{人类},就像\hateby{我}{翔}
% 为第一个参数指定默认值
\looklike{哈士奇}{狼}
\looklike[贼像]{哈士奇}{狼}
% 重定义已有的命令
\begin{abstract}
摘要内容...
\end{abstract}
% 定义新环境
\begin{myabstract}
新环境就是好...
\end{myabstract}
\begin{myabstract}[我的新环境的摘要标题]
自定义标题的新环境就是好...
\end{myabstract}
\end{document}