Latex的安装与使用
Latex环境配置与使用
- 环境安装
- Tex的下载与安装
- Tex Studio的安装
- Latex 编译原理
- 使用
- 简单使用
- 配置语法检查功能
- 清理编译过程中生成的辅助文件
- 数学公式的编辑
- 表的编辑
- 图的编辑
- 算法伪码排版
- 参考文献管理
环境安装
环境安装分两步:(1)安装 Tex live; (2)安装IDE:Lex Studio。其中Tex live是是Latex的一个发行版本,尽管Tex live本身带有编辑器,但是不好用,Lex Studio弥补了这一缺点,并且提供非常友好的界面,非常便于文档编辑和管理。
Tex的下载与安装
下载链接:l链接 , 具体下载流程参考:链接,下载完成后得到 texlive.iso镜像文件,然后进行安装。
Tex Studio的安装
下载链接:链接,下载完成后得到应用程序texstudio-x.xx.xx-win-qt5,进行安装即可。安装完成后启动tex Studio.
简单配置:
(1)设置行号:Options->Configure Tex Studio->Adv. Editor-> Show Line Numbers->选中All line numbers选项。
注:首先应当勾选Show adv. options,然后才能看到Adv. Editor这一栏。
(2) 改为中文界面:Options—> Configure Texstudio —> General—> Language—> zh_CN。
Latex 编译原理
TeX 将输入的源代码变成最终输出的排版结果经历一下几个步骤:
(1) token scanning(记号扫描): TeX 将最初读入源代码中的字符转化为“记号”的过程。字母等普通字符是记号,以 \ 开头的命令(或者叫“控制序列”,control sequence)也是记号。
(2) macro expansion(宏展开): 将 LaTeX 格式的命令、宏包中的命令、用户自定义的命令等展开,直到剩下需要 TeX 直接处理的原始命令(primitives)和字符等记号。在 TeX 中能展开的不仅是宏,一些原始命令也能够展开,如将数字输出为罗马数字格式的原始命令 \romannumeral。
(3) primitive interpretation: 将前两部得到的各种记号转化为排版的“原料”,遇到字符记号则输出字符,遇到构造盒子的命令则输出盒子,遇到一些参数赋值的命令则改变一些状态,等等。每个命令都起到什么作用,在 TeXbook 24-26 章有总结,不过想看懂那一部分,基本上要把 TeXbook 或者 TeX by topic 完整啃一遍。源代码经过前三步的“消化”,生成的排版“原料”以列表的形式组织,根部为一个垂直列表,粗略来讲,包括文字段落、公式、图表盒子等内容;文字段落为一个水平列表;公式则由数学列表的形式组织。在进行下一步之前,数学列表会转化为水平列表,怎么转化的,细节在 TeXbook 附录 G,当然一上来不见得有多少人啃得动。
(4) line breaking: 将水平列表根据给定的宽度断行,生成从上到下排布的一系列盒子。由(不那么)著名的 Knuth-Plass 算法实现。
(5) page breaking: 一页内容从上到下填满,则进行断页操作。这一个步骤可以被利用起来,制造一些特殊的中断,从而实现诸如 LaTeX 处理浮动体之类的操作。
(6) page building: 将前两步生成的页面盒子加上页眉页脚等内容,打包生成最终的页面,所有的字符、图像等排版元素的位置和大小固化在这个页面上。
(7) 将上一个步骤中生成的页面写入输出格式,如 DVI 或 PDF。
在编译的过程中会产生一些中间文件加粗样式:
(1) *.aux: 引用标记记录文件,用于再次编译时生成参考文献和超链接等。
(2) *.bbl: 由BiBTeX编辑.bib后创建的文献文件,再次编译时带入源文件生成文献列表。
(3) *.log: 编译过程记录文件,记录编译时出现的提示、警告和错误信息。
参考: https://www.zhihu.com/question/327762196
使用
简单使用
从模板开始编辑:首先准备好模板,例如IEEE Trans的模板,下载链接,然后File-> Open->选中要导入的文件->打开。
编译:选中Latex源文件(**.tex),然后点击 “绿色的右向三角形” 按钮编译,编译过程中会产生一些中间文件(原理中详述),编译成功会得到pdf文件(该文件与latex文件在同一目录),可用Adobe Acrobat打开,也可以点击 “放大镜” 按钮直接在内嵌界面中直接显示生成的pdf文件内容。
latex文件介绍: latex源文件的结构类似于超文本标记语言HTML,功能更为强大,不再赘述,关于latex文件的介绍详见 链接。并且提供各种各样的包,可以按照类似python的方式进行调用,从而可以轻松完成各种样式的排版。
配置语法检查功能
Options -> Configure TexStudio -> Language checking -> Default language:选择en_US.
清理编译过程中生成的辅助文件
Tools -> Clear auxiliary files,
数学公式的编辑
各种数学公式符号对应的标记参照:链接;
公示的引用:引用相应的标记即可,例如:\ref{Eq1}
;
示例一:单个公式
\begin{equation} \label{Eq1}
\setlength\abovedisplayskip{1pt}
{\rm MIC}(x,y)=\mathop{\max}_{a \cdot b < N^{\alpha}} I_{a,b}(x,y)/log_{2} \mathop{\max}(a,b)
\setlength\belowdisplayskip{1pt}
\end{equation}
示例二:公式组
\begin{eqnarray}
\hat{\phi}, \hat{\varphi}=\mathop{\arg\min}_{\phi, \varphi}l(\phi, \varphi, \hat{\pi}), \label{Eq3} \\
\hat{\pi}=\mathop{\arg\max}_{\pi}l(\hat{\phi},\hat{\varphi},\pi), \label{Eq4}
\end{eqnarray}
Latex公式的压缩
- 缩小公式内部的空隙宽度: 通过命令"\!"压缩公式中字符之间的间距;
- 缩小公式上下的空隙高度: 通过命令“
\setlength\abovedisplayskip{3pt}
” 和 “\setlength\belowdisplayskip{3pt}
”来分别设置公式上和下的空隙高度; - 将公式缩小为行内形式: 二项式系数、矩阵、累加缩小为行内形式,例:
\begin{eqnarray*}\dbinom{a}{b}\qquad\begin{pmatrix}a&b\\c&d\end{pmatrix}\qquad\sum_{k=1}^n k^2\\\tbinom{a}{b}\qquad\bigl(\begin{smallmatrix}a&b\\c&d\end{smallmatrix}\bigr)\qquad\begin{matrix}\sum_{k=1}^n k^2\end{matrix}
\end{eqnarray*}
表的编辑
表格常用的包:
\usepackage{threeparttable}
\usepackage{makecell}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{array}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{float}
几个需要注意的问题:
- 调节表格行间距:
\begin{spacing}{1.1}
- 表格缩放:
\resizebox{1.0\hsize}{!}{ xxxtable content xxx}
,该标记在表格超出页面时非常管用。 - 表格脚注:
\begin{tablenotes} \footnotesize \item[1] xxxx \item[2] xxxx. \end{tablenotes}
- 单/双栏表格:
\begin{table}
为单栏表,\begin{table*}
为跨栏表
其中每个item对应一个脚注;
5.表格位置控制:{table}有若干可选参数 [!htbp]
h代表here,将表格排在当前文字位置
t 表示将表格放在下一页的 top (页首)
b 表示将表格放在当前页的 bottom (底部)
!表示忽略美观因素,尽可能按照参数指定的方式来处理表格浮动位置。
表格将会按照所给参数,依次尝试按照每个参数进行排版,当无法排版时,将会按照下一个参数
5.调整表格距下文的间距:
在\begin{table}
中添加如下命令:
\vspace{-1em}
示例一:
\begin{table}[h]\begin{center}\begin{spacing}{1.1}\caption{Network configurations of RDAE.}\label{table1}\resizebox{1.0\hsize}{!}{%\begin{tabular}{|c|c|c|c|c|c|c|c|c|}\begin{tabular}{ccccccccc}%\hline\toprule\multirow{1}{*}{\makecell[{}{p{1.1cm}}]{\textbf{Module}}} & \multirow{1}{*}{\makecell[{}{p{1.1cm}}]{\textbf{Block}}} & \multirow{1}{*}{\makecell[{}{p{1.5cm}}]{\textbf{Layer}}} & \multirow{1}{*}{\makecell[{}{p{1.2cm}}]{\textbf{Kernel$^1$}}} &\multirow{1}{*}{\makecell[{}{p{1.5cm}}]{\textbf{Output$^1$}}} &\multirow{1}{*}{\makecell[{}{p{1.5cm}}]{\textbf{Stride/Factor}}} &\multirow{1}{*}{\makecell[{}{p{1.2cm}}]{\textbf{Pad.}}} &\multirow{1}{*}{\makecell[{}{p{1.2cm}}]{\textbf{Activ.}}} &\multirow{1}{*}{\makecell[{}{p{1.5cm}}]{\textbf{Drop rate.}}} \\%\hline\midrule\multirow{25}{*}{\makecell[{24}{p{1.2cm}}]{Conv. AE}} &\multirow{1}{*}{\makecell[{}{p{2cm}}]{ —— }} & Input & —— & ($L$,1)& —— & —— & —— & —— \\\cline{2-9}& \multirow{2}{*}{\makecell[{}{p{1.0cm}}]{block-1}} & Conv1D & (15, $b$) & ($L$, $b$) & 1/ & same & ReLU & —— \\\cline{3-9}& & Conv1D & (15, $b$) & ($L$/5, $b$) & 5/ & same & ReLU & —— \\\cline{2-9}& \multirow{3}{*}{\makecell[{}{p{1.0cm}}]{block-2}} & Conv1D & (15, 2$b$) & ($L$/5, $b$) & 1/ & same & ReLU & —— \\\cline{3-9}& & Conv1D & (15, 2$b$) & ($L$/25, 2$b$) & 5/ & same & ReLU & —— \\\cline{3-9}& & Dropout & —— & —— & —— & —— & —— & 0.1 \\\cline{2-9}& \multirow{3}{*}{\makecell[{}{p{1.0cm}}]{block-3}} & Conv1D & (15, 4$b$) & ($L$/25, 4$b$) & 1/ & same & ReLU & ——\\\cline{3-9}& & Conv1D & (15, 4$b$) & ($L$/50, 4$b$) & 2/ & same & ReLU & ——\\\cline{3-9}& & Dropout & —— & —— & —— & —— & —— & 0.1\\\cline{2-9}& \multirow{3}{*}{\makecell[{}{p{1.0cm}}]{block-4}} & Flatten & —— & $L$ x 32/50 & —— & —— & —— & —— \\\cline{3-9}& & Dropout & —— & —— & —— & —— & —— & 0.1\\\cline{3-9}& & Dense & —— & 32 & —— & —— & ReLU & —— \\\cline{2-9}& \multirow{1}{*}{\makecell[{}{p{1.0cm}}]{——}} & Dense & —— & $latent\_dim$ & —— & —— & None & —— \\\cline{2-9}& \multirow{4}{*}{\makecell[{}{p{1.1cm}}]{block-4'}} & Dense & —— & 32 & —— & —— & ReLU & —— \\\cline{3-9}& & Dense & —— & $L$x32/50 & —— & —— & ReLU & —— \\\cline{3-9}& & Dropout & —— & —— & —— & —— & —— & 0.1 \\\cline{3-9}& & Reshape & —— & ($L$/50, 4$b$) & —— & —— & —— & —— \\\cline{2-9}& \multirow{3}{*}{\makecell[{}{p{1.1cm}}]{block-3'}} & Conv1D & (15,4$b$) & ($L$/50, 4$b$) & 1/ & same & ReLU & —— \\\cline{3-9}& & UpSample & —— & ($L$/25, 4$b$) & /2 & —— & —— & —— \\\cline{3-9}& & Dropout & —— & —— & —— & —— & —— & 0.1 \\\cline{2-9}& \multirow{3}{*}{\makecell[{}{p{1.1cm}}]{block-2'}} & Conv1D & (15, 2$b$) & ($L$/25, 2$b$) & 1/ & same & ReLU & —— \\\cline{3-9}& & UpSample & —— & ($L$/5, 2$b$) & /5 & —— & —— & —— \\\cline{3-9}& & Dropout & —— & —— & —— & —— & —— & 0.1 \\\cline{2-9}& \multirow{3}{*}{\makecell[{}{p{1.1cm}}]{block-1'}} & Conv1D & (15, $b$) & ($L$/5, $b$) & 1/ & same & ReLU & —— \\\cline{3-9}& & UpSample & —— & ($L$, $b$) & /5 & —— & —— & —— \\\cline{3-9}& & Conv1D & (15, 1) & ($L$,1) & 1/ & same & None & —— \\\hline\multirow{5}{*}{\makecell[{}{p{1.2cm}}]{Domain cls.}} & \multirow{5}{*}{\makecell[{}{p{1.0cm}}]{ ——$^2$}}& Dense & —— & $latent\_dim$ & —— & —— & None & —— \\\cline{3-9}& & BatchNorm & —— & —— & —— & —— & ReLU & —— \\\cline{3-9}& & Dense & —— & $latent\_dim$ & —— & —— & None & —— \\\cline{3-9}& & BatchNorm & —— & —— & —— & —— & ReLU & —— \\\cline{3-9}& & Dense & —— & #records & —— & —— & None & —— \\%\hline\bottomrule\end{tabular}}\begin{tablenotes}\footnotesize\item[1] $^1$$(a, b)$, $a$ denotes kernel size (in ‘Kernel’ column) or output dimension (in ‘Output’ column), and $b$ denotes the number of channels.\item[2] $^2$'——' denotes the corresponding attribute is not applicable to the layer, ‘None’ denotes linear activation.\end{tablenotes}\end{spacing}\end{center}
\end{table}
图的编辑
常用包:
\usepackage{subfigure}
\usepackage{graphicx}
几点说明:
- 多张图的横排与竖排:同一个
\subfigure
下每个\includegraphics
对应的图之间是竖排的,不同\subfigure对应的图之间是横排的;
特别注意:每个\subfigure
包含的图(可以是一张或者多张)拥有一个子标记label,例如:(a); - 调整图大小:可通过
\includegraphics[scale=.55]
缩放图片,或者通过\includegraphics[width=1.5in,height=1.0in]
直接设置图片的高和宽; - 单/双栏图:
\begin{figure}
为单栏图,\begin{figure*}
为跨栏图; - 调整图距上下文的空白间距
如下两行命令放在\begin{figure}
下面:
\setlength{\abovecaptionskip}{2pt}
\setlength{\belowcaptionskip}{-2pt}
示例一:
\begin{figure*}\centering\subfigure[]{\label{Fig:5-1-1}\begin{minipage}{0.25\linewidth}\includegraphics[width=1.5in,height=1.0in]{figs/preprocess/filter-ppg-pos-0-0-31}\includegraphics[width=1.5in,height=1.0in]{figs/preprocess/filter-ppg-pos-1-421-37}\end{minipage} }%\subfigure[]{\label{Fig:5-1-2}\begin{minipage}{0.25\linewidth}\includegraphics[width=1.5in,height=1.0in]{figs/preprocess/filter-abp-pos-0-87-36}\includegraphics[width=1.5in,height=1.0in]{figs/preprocess/filter-abp-pos-0-1140-19}\end{minipage} }%\subfigure[]{\label{Fig:5-1-3}\begin{minipage}{0.25\linewidth}\includegraphics[width=1.5in,height=1.0in]{figs/preprocess/abp-low-quality2-sql-0-0-0-pos-0-310-32}\includegraphics[width=1.5in,height=1.0in]{figs/preprocess/abp-low-quality2-sql-0-0-0-pos-0-472-30}\end{minipage} \\\label{Fig:5-1-4}\begin{minipage}{0.25\linewidth}\includegraphics[width=1.5in,height=1.0in]{figs/preprocess/abp-low-quality2-sql-0-0-0-pos-0-516-7}\includegraphics[width=1.5in,height=1.0in]{figs/preprocess/abp-low-quality2-sql-0-0-0-pos-0-99-5}\end{minipage} } \caption{Preprocess results and excluded abnormal segments. (a) PPG signal; (b) ABP signal; (c)excluded abnormal ABP segments.} \label{Fig:5}
\end{figure*}
算法伪码排版
常用包:
\usepackage{algorithm}
%\usepackage{algorithmic} % this will cause row number error in algorithm template.
\usepackage{algpseudocode}
\usepackage{amsmath}
\renewcommand{\algorithmicrequire}{\textbf{Input:}} % Use Input in the format of Algorithm
\renewcommand{\algorithmicensure}{\textbf{Output:}} % Use Output in the format of Algorithm
其中 algorithmic
和algorithmicx
两个包的标记有很多相似但又不同的地方,这两个包包含的标记见:链接, 实际使用中建议只是用其中一个,不要混用。
示例一(基于algorithmic包):
\begin{algorithm}[h]\setstretch{0.9}\caption{RDAE}\label{alg::RDAE}\begin{algorithmic}[1]\Require$D$: data, \{($x^{i}$, $y^{i}$)\};$E_{\phi}$: encoder;$D_{\varphi}$: decoder;$D_{\pi}$: domain classifier;$B$: batchsize;$K$: number of inner iterations;$maxEpoch$: maximum number of epoches;$\alpha$: learning rate;$\lambda$: weight factor\Ensureoptimal model parameterized with $\varphi$ and $\phi$\State $t=0$;\State initialize parameters $\phi$, $\varphi$ and $\pi$;\Repeat \State $t \leftarrow t+1$;\For{each $k \in [1,K]$} \State sample $\{(x^{i}, y^{i})\}^{B}_{i=1}$ from dataset $D$; \State compute latent code: $z^{i}=E_{\phi} (x^{i})$ for $i \in {1,2,...,B}$; \State compute output of domain classifier: $\hat{d}_{x^{i}}=D_{\pi} (z^{i})$ for $i \in {1,2,...,B}$; \State compute gradient w.r.t $\pi$: $g_{\pi} \leftarrow \bigtriangledown{\pi} \frac{1}{B} \sum_{i=1}^{B} L_{d} (\hat{d}_{x^{i}}, d_{x^{i}})$; \State update domain classifier: $\pi \leftarrow \pi - \alpha \cdot g_{\pi}$; \EndFor\State sample $\{(x^{i}, y^{i})\}^{B}_{i=1}$ fr{\tiny \label{key}}om dataset $D$; \State compute latent code: $z^{i}=E_{\phi} (x^{i})$ for $i \in {1,2,...,B}$;\State compute output of domain classifier: $\hat{d}_{x^{i}}=D_{\pi} (z^{i})$ for $i \in {1,2,...,B}$; \State compute output of decoder: $\hat{y}^{i}=D_{\varphi}(z^{i})$ for $i \in {1,2,...,B}$; \State compute gradient w.r.t $\phi$: $g_{\phi} \leftarrow \bigtriangledown{\phi} \frac{1}{B} \sum_{i=1}^{B} {L_{r}(\hat{y}^{i}, y^{i}) - \lambda \cdot L_{d}(\hat{d}_{x^{i}}, d_{x^{i}})}$; \State update encoder: $\phi \leftarrow \phi - \alpha \cdot g_{\phi}$; \State compute gradient w.r.t $\varphi$: $g_{\varphi} \leftarrow \bigtriangledown{\varphi} \frac{1}{B} \sum_{i=1}^{B} L_{r}(\hat{y}^{i}, y^{i})$; \State update decoder: $\varphi \leftarrow \varphi - \alpha \cdot g_{\varphi}$; \Until {converged \textbf{or} $t > maxEpoch$} \end{algorithmic}
\end{algorithm}
更多示例参见: 链接1, 链接2
参考文献管理
Latex中,一般参考文献的引用全部位于**.bib文件中,可以从一下两个途径获取latex样式的引用格式:
(1)research Gate: 找到文献后->cite->Bib tex -> copy-> past;
(2)google: 找到文献后->cite->Bib tex -> copy-> past;
令:将arXiv引用转化为Bibtex引用样式,可通过在线转换工具:链接, 只需输入paper的ID即可。
特别注意:更新完bib文件,需要编译两次后,正文中才能正确显示引用,否则在引用位置处会出现??。
当然还有一种方式是在tex文件中使用 begin{thebibliography}{00}, 然后通过\bibitem 来直接插入参考文献,这种方式不需要bib文件。详情参考https://blog.csdn.net/cdpxc/article/details/119784556
Latex的安装与使用相关推荐
- LaTeX的安装教程及问题记录
安装教程 我的安装过程参考的博客: LaTeX的安装教程(Texlive 2020 + TeX studio) 遇到的问题 TLUtils::install_packages: Failed to i ...
- LaTex学习-安装
LaTex学习-安装 感谢博客指导: https://blog.csdn.net/zaishuiyifangxym/article/details/88170827?ops_request_misc= ...
- LaTeX 如何安装一些非免费字体 getnonfreefonts
LaTeX 如何安装一些非免费字体 getnonfreefonts 在 LaTeX 中,有些字体是可以免费使用的,但是因为这些字体不允许收费分发,所以在本地化的安装里通常没有提前包括它们.本文介绍如何 ...
- mac上Latex的安装及使用教程
latex的安装 官网下载地址:http://tug.org/mactex/ 以前在 Mac 上装 Tex/LaTeX 很麻烦,现在容易多了,只需要下载单个软件包 MacTeX.mpkg.zip 即可 ...
- Visio21 、Endnote X9.1、Endnote20、Endnote21、Endnote22、Latex 22安装破解版
1. Visio21 来源:Visio 2021安装教程 [下载链接]: https://pan.baidu.com/s/1rzEoMIkws6TX3n9M15B0kw [提取码]: hrrj(建议复 ...
- Latex 下载安装及使用教程
方便自己找:Latex 下载安装及使用教程 一 介绍 (一)关于 LaTeX和CTeX 二 TexLive2018+WinEdt10.3安装 (一)基本安装 (二)使用介绍 (三)完整的入门资源: 一 ...
- Linux 下 LaTeX 2018 安装与使用
一.背景 前两天在自己的 Jupyter 服务器上想要把 notebook(.ipynb) 导出为 pdf 时发现 xelatex 没有安装 500 : Internal Server Error 如 ...
- Latex之安装GBK字体
Latex下支持中文的方式有多种,其中之一就是应用CJK宏包.当Tex发行版,如MikTex,安装CJK后,可以使用中文.但是,发行版中包含的字体较少,例如MikTex,当安装完CJK-Fonts后, ...
- LaTeX环境安装及入门之入门使用
写在前面: 1.LaTeX不简单,这里只是简单的写一下比入门更简单的一些操作. 2.关于LaTeX和Tex的关系 图源百度百科 一. TeX Live的安装 0. TeX Live和LaTeX的区别 ...
最新文章
- drive数据集_英伟达的最强人脸GAN开源了,它吃的高清数据集也开源了
- MySQL笔记-CURRENT_TIMESTAMP()和ON UPDATE及索引相关
- 百度网盘查看分享的文件
- apache php设置404页面,详细介绍通过配置Apache实现404页面替换
- 输出 系统 环境变量
- 服务器中W3SVC1文件夹的文件,完美解决IIS 服务器无法加载应用程序 '/LM/W3SVC/1/ROOT'。错误是 '没有注册类别...
- retrievefile文件字节为0_linux环境下下 FTPClient.retrieveFile() 下载稍大一点的文件就卡死了-问答-阿里云开发者社区-阿里云...
- js中立即执行函数会预编译吗_javascript引擎执行的过程的理解--执行阶段
- 笔录软件在linux系统,weblogic的在redhat linux下使用笔录
- 魔兽国服修改服务器地址,魔兽国服退役服务器上架暴雪官方商店
- 多边形扩展和收缩(凸多边形和凹多边形)
- word里双横线怎么打_Word中下划线怎么打出来
- STM32+AD7606
- 弘辽科技:端午节拼多多有优惠吗?力度如何?
- 推荐一本书:《Visual C++程序开发范例宝典》——你可以找到你想要的实例
- TI PFC+LLC解决方案在工业电源中的应用-电子研习社
- Scrapy框架流程图解析
- socket编程之accept()函数
- mysql数据库 博客_mysql数据库教程--第 页-杨雨个人博客-关注互联网和搜索引擎的技术博客...
- 用Python爬取wallhaven高清原图