前言
主要是对使用过程中的问题进行记录
正文
- 公式可以去这里查找
- 给图片设置label后,\ref{}标号是section的标号,原因在于label要放在caption下面
- latex插入图片
\begin{figure}[htbp]
\centering
\includegraphics[width=.4\textwidth]{figure/regression_tree.png} %1.png是图片文件的相对路径
\caption{回归决策树} %caption是图片的标题
\label{img} %此处的label相当于一个图片的专属标志,目的是方便上下文的引用
\end{figure}
latex两个图并排
\usepackage{caption}
\usepackage{subfigure}
%导言区域要添加以上两个包
\begin{figure}[htbp]
\centering %居中
\subfigure[name of the subfigure] %第一张子图
{
\begin{minipage}{7cm}
\centering %子图居中
\includegraphics[scale=0.5]{pic1.jpg} %以pic.jpg的0.5倍大小输出
\end{minipage}
}
%这里空行则两张图上下排列。这里其实指的是图片之间的间隔,可以使用\quad,这样也能实现田字形的排列
\subfigure[name of the subfigure] %第二张子图
{
\begin{minipage}{7cm}
\centering %子图居中
\includegraphics[scale=0.8]{fig2.jpg} %以pic.jpg的0.5倍大小输出
\end{minipage}
}
\caption{name of the figure} % %大图名称
\label{fig:1} %图片引用标记
\end{figure}
- latex插入代码:
\usepackage{listings}
\usepackage{textcomp}
\lstset{
columns=fixed,
numbers=left, % 在左侧显示行号
numberstyle=\tiny\color{gray}, % 设定行号格式
frame=none, % 不显示背景边框
backgroundcolor=\color[RGB]{245,245,244}, % 设定背景颜色
keywordstyle=\color[RGB]{40,40,255}, % 设定关键字颜色
numberstyle=\footnotesize\color{darkgray},
commentstyle=\it\color[RGB]{0,96,96}, % 设置代码注释的格式
stringstyle=\rmfamily\slshape\color[RGB]{128,0,0}, % 设置字符串格式
showstringspaces=false, % 不显示字符串中的空格
language=python, % 设置语言
escapeinside=``
}
\begin{lstlisting}
def sigmoid(x):
# `(需要填写的地方,输入x返回sigmoid(x))`
return 1/(1+np.exp(-x))
def deriv_sigmoid(x):
# `(需要填写的地方,输入x返回sigmoid(x)在x点的梯度)`
return sigmoid(x)*(1-sigmoid(x))
\end{lstlisting}
- 等式
\begin{equation*}
\begin{aligned}
SOL&=\sum_i^n SOL_i\\
&=
\end{aligned}
\end{equation*}
- 算法
\begin{algorithm}[H]
\caption{ Weighted Max $k$-cut}
\textbf{Input}:
The undirected graph $G(V,E)$ with positive edge weights
\begin{algorithmic}[1]
\FOR{$i\in V$}
\STATE {Find a disjoint set $S_j$ w.r.t $i$ with the maximum cost.}
\STATE {Put $i$ in $S_j$.}
\ENDFOR
\STATE Return the $k$-cut.
\end{algorithmic}
\end{algorithm}
- 参考文献
\newcommand{\supercite}[1]{\textsuperscript{\cite{#1}}}
\bibliographystyle{plain}
\bibliography{ref.bib}
\small
\begin{thebibliography}{99}
\setlength{\parskip}{0pt} %段落之间的竖直距离
\bibitem{ref1}周志华.机器学习[M].北京:清华大学版社,2016.
\end{thebibliography}
插入超链接
\usepackage[colorlinks,linkcolor=red]{hyperref}
\url{}
\href{www}{}
中文论文
往往与使用xelatex有关。
引用网络资源要使用@online类型标签
@online{引用ID,
author = {BaiDu},
title = {Apollo Home Page},
url = {https://github.com/apolloauto},
year = {2019}
}
引用学位论文
@phdthesis{论文索引,
title={文章标题},
author={作者},
school={作者申请学位的学校},
year={申请学位论文时间},
}
引用会议论文用@conference
,不用@inproceedings
插入多张图,中间空行则上下排列
\begin{figure}[ht]
\begin{subfigure}{1.\textwidth}
\centering
\includegraphics[width=.82\textwidth]{imgs/lt.pdf}
\caption{整体体系架构}
\label{lt1}
\end{subfigure}
\begin{subfigure}{1.\textwidth}
\centering
\includegraphics[width=.82\textwidth]{imgs/lt2.pdf}
\caption{训练架构}
\label{lt2}
\end{subfigure}
\caption{联盟训练架构图}
\label{lt}
\end{figure}