LaTex数学符号,公式解析与伪代码书写

数学符号

LaTex常用的具有数学意义的符号:
参考链接:https://blog.csdn.net/lanchunhui/article/details/54633576
以下需要使用宏包:\usepackage{amsmath,amssymb,amsfonts}

mathbb:blackboard bold,黑板粗体 
mathcal:calligraphy(美术字) 
mathrm:math roman 
mathbf:math boldface

花体\mathcal实例:

  • \mathcal D: D \mathcal D D常用来表示数据集
  • \mathcal L: L \mathcal L L常用来表示损失函数
  • \mathcal N: N \mathcal N N常用来表示正态分布
  • \mathcal U: U \mathcal U U常用来表示均匀分布

空心体\mathbb实例:

  • \mathbb D: D \mathbb D D

将字母的斜体变为正体:
x \Rightarrow {\rm{x}} x ⇒ x x \Rightarrow {\rm{x}} xx
加粗符号:
需要使用宏包:\usepackage{bm}
w \Rightarrow \bm{w} w ⇒ w w \Rightarrow \bm{w} ww
将字母的斜体变为正体并加粗:
x \Rightarrow {\mathbf{x}} x ⇒ x x \Rightarrow {\mathbf{x}} xx
字母下标:\mathop{\mathbb{E}}_{x\sim pX(x)} 下标在字母的正下方

行间公式

\begin{equation}
	y = \sin{(x)}
\end{equation}

y = sin ⁡ ( x ) y = \sin{(x)} y=sin(x)
实现公式的对齐换行:

\begin{align}
		&y=x+1 \notag \\% 表示不加编号
		&y=\sin{(x)} \tag{1.1} \\  % 在定义编号
		&y=x  % 常规编号
	\end{align} 

在这里插入图片描述

伪代码书写

参考:
https://blog.csdn.net/qq_34369618/article/details/61205638
https://blog.csdn.net/lwb102063/article/details/53046265

实例:

\documentclass{article}  
% 所用宏包
\usepackage{algorithm}  
\usepackage{algorithmicx}  
\usepackage{algpseudocode}  
\usepackage{amsmath}  

\floatname{algorithm}{Algorithm}  % 算法的头名字
\renewcommand{\algorithmicrequire}{\textbf{Input:}} % 输入格式  
\renewcommand{\algorithmicensure}{\textbf{Output:}}  % 输出格式

\begin{document}  
	\begin{algorithm}  
		\caption{The example of using LaTex}  
		\begin{algorithmic}[1] %每行显示行号  
			\Require $Array a$,$n$  % 算法的输入
			\Ensure sum of $a$       % 算法的输出
			
			\Function {MergerSort}{$Array, left, right$}  % 函数开始
			\State $result \gets 0$  
			
			\If {$left < right$}  % if的开始
			\State $middle \gets (left + right) / 2$  % 书写语句

			\State $result \gets result +$ \Call{Merger}{$Array,left,middle,right$}  % 调用函数
			\EndIf    % if的结束
			\State \Return{$result$}  % 返回结果 
			\EndFunction  % 结束函数
			
			\State  % 为空内容可以实现空一行

			\While{$i<middle$ \textbf{and} $j<right$}  % while的开始
			\If{$Array[i]<Array[j]$}  
			\State $B[k++]\gets Array[i++]$  
			\Else  
			\State $B[k++] \gets Array[j++]$  
			\State $result \gets result + (middle - i)$  
			\EndIf  
			\EndWhile  % 结束while语句
			
			\For{$i = 0 \to k-1$}   % for的开始
			\State $Array[left + i] \gets B[i]$  
			\EndFor  % for的结束
		\end{algorithmic}  
	\end{algorithm}  
\end{document}  

这里写图片描述
但是对你IEEE的LaTex模板,上述的命令语句必须改为大写,且引入的宏包也不相同。上述所用宏包为algorithmicx,而IEEE模板中所用宏包为algorithmic。两者命令的差异:https://blog.csdn.net/yeyang911/article/details/41758039。 在algorithmic中没有找到与定义函数function相关的命令。

\usepackage{algorithmic}
\usepackage{algorithm}  
\begin{algorithm}  
		\caption{The example of using LaTex}  
		\begin{algorithmic}[1] %每行显示行号  
			\REQUIRE $Array a$,$n$  % 算法的输入
			\ENSURE sum of $a$       % 算法的输出
			
			\STATE $result \gets 0$  
			
			\IF {$left < right$}  % if的开始
			\STATE $middle \gets (left + right) / 2$  % 书写语句
			
			\STATE $result \gets result +$ %\CALL{Merger}{$Array,left,middle,right$}  % 调用函数
			\ENDIF    % if的结束
			\STATE \RETURN{$result$}  % 返回结果 

			
			\STATE  % 为空内容可以实现空一行
			
			\WHILE{$i<middle$ \textbf{and} $j<right$}
			\IF{$Array[i]<Array[j]$}  
			\STATE $B[k++]\gets Array[i++]$  
			\ELSE 
			\STATE $B[k++] \gets Array[j++]$  
			\STATE $result \gets result + (middle - i)$  
			\ENDIF  
			\ENDWHILE  % 结束while语句
			
			\FOR{$i = 0 \to k-1$}   % for的开始
			\STATE $Array[left + i] \gets B[i]$  
			\ENDFOR  % for的结束
		\end{algorithmic}  
	\end{algorithm}

这里写图片描述

  • 13
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值