用LaTex写伪代码的代码框架

书写工具

1.latex编辑器

Overleaf, Online LaTeX EditorAn online LaTeX editor that’s easy to use. No installation, real-time collaboration, version control, hundreds of LaTeX templates, and more.https://www.overleaf.com/

2.Mathtype

3.Axmath

基础框架

1.for循环

$
\For{$i = 0,1,\cdots, b-1$}{
    \For{$j = 0,1,\cdots, h\times w-1$}{
        \For{$x = 0,1,\cdots, N-1  $ }{
            \For{$y = 0,1,\cdots, N-1  $ }{
                $
                r=\sqrt{\text{(}\left( x-\frac{N}{2} \right) ^2+\left( y-\frac{N}{2} \right) ^2}\\
                $
                \eIf{$r \le \frac{N}{2}$}{
                    $K_{ij}^{xy}=C\_weight$
                }{
                    $K_{ij}^{xy}=S\_weight$
                }
            }
        }
        \EndFor % 结束内层循环
    $EF_{ij}=K_{ij}\bullet OF_{ij}^{N\times N}$
    }
}
\EndFor % 结束外层循环
$

2.if语句

\eIf{i = 0}{
        $fd1_i, fd2_i = F_{DDC}(\text{Z}_{in})$
    }{
        \emph{$fd1_i, fd2_i = F_{DDS}(fd2_{i - 1})$}
    }

整体框架

代码

\documentclass{ctexart}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\usepackage [T1] {fontenc}
\usepackage{amsmath} 
\usepackage{times}
\renewcommand\linenumberfont{\normalfont\scriptsize\textcolor{gray}}
\renewcommand\thelinenumber{\textcolor{gray}{\arabic{linenumber}:}}
\usepackage{ragged2e} % 导入 ragged2e 包以支持对齐命令
\usepackage{lineno}
\usepackage{setspace} % 导入 setspace 宏包

% 减少段落之间的间距
\setlength{\parskip}{0pt}

% 设置行间距为单倍行距
\renewcommand{\baselinestretch}{1}

\begin{document}
% 修改编号 0 + 1
\setcounter{algocf}{1}
\begin{algorithm}[H]
\SetAlgoLined % 显示 end
\caption{Training steps of the GOFM}% 算法名字

\KwIn{Input a SAR image $\mathbb{Z}_{in}$.}% 输入参数
        
\KwOut{Filtered image $Z_{u - b}$.}% 输出

\KwData{
    \begin{spacing}{1} % 设置行间距为 1 倍
        $
\begin{array}{l}
   \ \ \ \ \ \ \ F_{DDC}:Dynamic\_Down\_Conv\\
   \ \ \ \ \ \ \ F_{DDS}:Dynamic\_Down\_Sampling\\
   \ \ \ \ \ \ \ F_{DUS}:Dynamic\_Up\_Sampling\\
   \ \ \ \ \ \ \ F_{DAO}:Dynamic\_Aux\_Out\\
\end{array}
$
    \end{spacing}
}

\For{i = 0,1,2}{\label{forins}
    \eIf{i = 0}{
        $fd1_i, fd2_i = F_{DDC}(\text{Z}_{in})$
    }{
        \emph{$fd1_i, fd2_i = F_{DDS}(fd2_{i - 1})$}
    }
}

\For{i = 0,1,2,3}{\label{forins}
    \eIf{i = 0}{
        $fu, ao_i = F_{DUS}(fd2_{-1}, fd1_{-1}, tap = 1)$
    }{
        \eIf{i $\neq$ 3}{
            $fu, ao_i = F_{DUS}(fu, fd1_{-1 - i}, tap = 1)$
        }{
            \emph{$fu, ao_i = F_{DUS}(fu, fd1_{-1 - i}, tap = 0)$}
        }
    }
}
$
Target\_size=\left( fu.shape\left( 2 \right) ,fu.shape\left( 3 \right) \right) 
$\\
$
\text{Interpolate }ao\  \text{by }Target\_size $
\rightarrow ut 
$.
$

$\text{Concatenate\ $ut$\  }.$$
\rightarrow ut 
$.\\
$
Z_{u-b}=F_{DAO}\left( ut \right) 
$
\end{algorithm}
\end{document}

效果

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值