在WORD中插入LATEX伪代码

本文最后更新于:2022年4月24日 下午

在WORD中插入LATEX伪代码

参见博客:latex伪代码—-word中插入latex伪代码

工具准备:

1.下载并安装Aurora,及注册,下载文件见网盘aurora和注册机。

使用:

1.word中插入-对象-Aurora equation

image_1bvmj7n9iuimdbq1fk1tki4p49.png-52.4kB

2.设置包:Properties-packages

image_1bvmjbmr0m88130tenkcr4v9f2m.png-95.2kB

1
2
3
4
5
6
7
\usepackage{CJK}
\usepackage{ctex}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\usepackage{amsmath}

3.输入伪代码的代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
%\floatname{algorithm}{算法}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\begin{algorithm}[H]
\caption{\textbf{Spectral Clustering}}
\begin{algorithmic}[1] %每行显示行号
\Require Affinity Matrix W, Cluster num $k$
\Ensure Clustering results
\Function {SpectralClustering}{$W,k$}
\State $D \gets diag(sum(W))$ //Calculate degree matrix
\State $L \gets D-W$ //Construct Laplacian matrix
\State $L_{nor} \gets (D^{-1/2})*L*(D^{-1/2})$ //Construct normalized Laplacian matrix
\State do Eigendecomposition of $L_{nor}$
\State do K-means of feature vector
\State \Return{$result$}
\EndFunction
\end{algorithmic}
\end{algorithm}

效果如下:

image_1c05ktoah1u19hs5nbc1g0ko5om.png-53.9kB

4.同一文章中插入第二个伪代码,显示algorithm 2方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
%\floatname{algorithm}{算法}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\begin{algorithm}[H]
\setcounter{algorithm}{1} #表示该伪代码为algorithm2(1+1)
\caption{\textbf{Shelves distribution}}
\begin{algorithmic}[1] %每行显示行号
\Require Cluster results,SKU historical delivery frequency
\Ensure Shelves layout
\State Determine the number of shelves that each cluster should be assigned to each subdivision based on the number of shelves that each partition can hold
\State Assign shelves within each cluster to each partition
\State Sort the shelves of each partition by frequency
\State \Return{$result$}
\end{algorithmic}
\end{algorithm}

效果如下:

image_1c05krr8f8ap1hc61kpe120r5tj9.png-50.3kB


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!