【Latex】记录写毕业论文时用到的操作

a.公式算法类

1.公式字体

正常来讲,论文中的英文和数学公式需要使用Times New Roman字体,但是LaTeX 无法设置整套数学字体为 Times New Roman。Times New Roman 字体缺乏整套数学符号、缺乏排版公式所需的间距等信息(在 OTF 字体中,这些信息储存在 MATH 表中)。通过 mathspec 宏包,LaTeX 可以设置数学模式下的字母为 Times New Roman,注意这可能需要手动调整符号间距。1

实例:

%导言区加入 
\usepackage{fontspec}   
\setmainfont{Times New Roman}

效果:
在这里插入图片描述

2.公式编号

直接使用[ ]进入数学环境编辑的公式意义为equation*环境,是不会自动编号的,若需要自动编号,需要用equation环境。

实例:

\begin{equation}
    a + b = b + a
\end{equation}

效果:
在这里插入图片描述

3.将公式组合成块

实际可能遇到多行公式组合在一起成为一个公式。这时常用的是cases环境,每行公式使用&分隔为两部分,表示前面的值和后面的条件。

实例:

\begin{equation}
	\Theta_{t,j}^{l}= \Theta(V_i^l(t-1) + Z_i^l(t) - V_{thr}),\text{with }
	\Theta(x) = 
	\begin{cases}
		1, & \text{if } x \ge 0; \\
		0, & \text{else.}
	\end{cases}
\end{equation}

效果:
在这里插入图片描述

4.算法表示

· algorithmicx是第二代算法排版环境
· algorithm2e是第三版算法排版环境

· algorithmicx实例(来源:https://blog.csdn.net/ChinaZm/article/details/123211818

\documentclass{article}
\title{Test title}
\author{ Mary\thanks{E-mail:*****@***.com}
	\and Ted\thanks{Corresponding author}
	\and Louis}
\date{\today}
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithm}[h] 
	\caption{Conjugate Gradient Algorithm with Dynamic Step-Size Control} 
	\label{alg::conjugateGradient} 
	\begin{algorithmic}[1] 
		\Require 
		$f(x)$: objective funtion; 
		$x_0$: initial solution; 
		$s$: step size; 
		\Ensure 
		optimal $x^{*}$ 
		\State initial $g_0=0$ and $d_0=0$; 
		\Repeat 
		\State compute gradient directions $g_k=\bigtriangledown f(x_k)$; 
		\State compute Polak-Ribiere parameter $\beta_k=\frac{g_k^{T}(g_k-g_{k-1})}{\parallel g_{k-1} \parallel^{2}}$; 
		\State compute the conjugate directions $d_k=-g_k+\beta_k d_{k-1}$; 
		\State compute the step size $\alpha_k=s/\parallel d_k \parallel_{2}$; 
		\Until{($f(x_k)>f(x_{k-1})$)} 
	\end{algorithmic} 
\end{algorithm}
\end{document}

效果:
在这里插入图片描述

推荐使用algorithm2e宏包,在导言区加入:

\usepackage[ruled,linesnumbered,noend]{algorithm2e}

ruled表示:算法标题在上面,不加的话默认在下面。
linesnumbered表示算法显示行数。
noend表示for,if等命令没有end作为结束。

实例:

\begin{algorithm}[H]
	\caption{Channel-wise normalization}%算法名字
	\SetKwBlock{Begin}{}{end}
	//Calculate maximum activation($\lambda$) for each channel from training dataset \\
	\LinesNumbered %要求显示行号
\For{$l\; in\; layers$}{
    \For{$j\; in\, output\; channels$}{
		 $\lambda_j^l=max(A_J^l)$ \\
	}
}
	//Apply channel-norm on inference(test dataset) \\
	\For{$l\; in\; layers$}{
    \For{$j\; in\, output\; channels$}{
		 $\tilde{b}_j^l = b_j^l \; / \; \lambda _j ^l$
		\For{$i\; in\, input\; channels$}{
			\eIf{$l=first \; layer$}{
				$\tilde{w}_{i,j}^l=w_{i,j}^l \; / \; \lambda_j^l$
			}{
				$\tilde{w}_{i,j}^l=w_{i,j}^l \; / \; \lambda_j^l \; \lambda_i^{l-1}$
			}
		}
	}
}
\end{algorithm}

效果:
在这里插入图片描述
更多算法格式参考Latex algorithm2

b.图片表格类

1. 图片引用

图片引用中,一般使用figure环境,建议使用\includegraphics[width=1\textwidth](yourfigure.png)表示图片,这里的1表示相对全文宽度的比例。其中\setlength{\abovecaptionskip}表示caption图注与图片的距离。\setlength{\belowcaptionskip}{0cm} 表示caption图注文字与下一自然段的距离。

实例:

\begin{figure}[htbp]
	\includegraphics[width=1\textwidth]{figures/ssdnet.png}
	\setlength{\abovecaptionskip}{0cm}  
	\setlength{\belowcaptionskip}{0cm}  
	\caption{ssd网络结构}
\end{figure}

效果:
在这里插入图片描述

2.表格制作

表格一般使用tabular环境,紧接在环境后的|表示一条竖线。r表示右对齐。
如果需要合并表格,需要用\multicolumn指令,其后的数字表示合并几行\列。
\hline命令表示画一条横线。

实例:

{
\begin{center}
\begin{tabular}{|rr|}
	\hline
	feature map & 大小\\
	\hline
	Conv4\_3 & 38*38\\
	Conv7 & 19*19\\
	Conv8\_2 & 10*10\\
	Conv9\_2 & 5*5\\
	Conv10\_2 & 3*3\\
	Conv11\_2 & 1*1\\
	\hline
\end{tabular}
\end{center}
}

效果:
在这里插入图片描述

c.参考文献类

推荐使用natbib宏包进行引用,在导言区加入:

\usepackage[numbers,square]{natbib}

直接在需要引入的地方加\cite{}即可,如需引用右上角数字标(默认为作者,年份方框标),在导言区新加入:

\newcommand\mycite[1]{{\setcitestyle{square,super}\cite{#1}}}
\newcommand\mycitex[1]{{\setcitestyle{authoryear,round}\cite{#1}}}

实例:

Seijoon Kim等人研究了SNN在更具挑战性的对象检测任务中的性能下降\mycite{Spiking-yolo}

根据\mycitex{2015Fast}提出的$\mathbf{Data-Base\; Normalization}$方法

在这里插入图片描述
在这里插入图片描述

参考


  1. LaTeX如何设置数学字体为Times New Roman? ↩︎

  2. Latex algorithm ↩︎

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值