10 使用algorithmicx宏包实现论文mamba中算法图微调问题

发布于 2024-08-26 22:06:26

希望复现下面的效果
image.png

下面是代码的MWE(需要使用pdflatex编译)

% pdflaTeX for libertine fonts
\documentclass[12pt,a4paper]{article}
\usepackage[margin=1.2cm]{geometry}
\usepackage{libertineRoman}
\usepackage{libertineMono}
\usepackage{biolinum}
\usepackage[libertine]{newtxmath}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{algorithm}
\usepackage{algpseudocode}
\algnewcommand\algorithmicinput{\textbf{Input:}}
\algnewcommand\Input[1]{\item[]\algorithmicinput\ #1}
\algnewcommand\algorithmicoutput{\textbf{Output:}}
\algnewcommand\Output[1]{\item[]\algorithmicoutput\ #1}
\pagestyle{empty}
\begin{document}
\lipsum[1]

\begin{minipage}{.48\textwidth}
    \begin{algorithm}[H]%此处为什么一定要使用[H]参数,不太懂什么par mode
        \centering
        \caption{SSM(S4)}
        \begin{algorithmic}[1]
            \Input{$x:(B,L,D)$}
            \Output{$y:(B,L,D)$}
            \State $A:(D,N) \leftarrow \text{Parameter}$ \par \Comment{$\text {Represents structured}\ \ N \times N\ \ \text{martix}$}
            \State $B:(D,N) \leftarrow \text{Parameter}$ 
            \State $C:(D,N) \leftarrow \text{Parameter}$
            \State $\Delta:(D) \leftarrow \tau_\Delta(\text{Parameter})$
            \State $\bar{A},\bar{B}:(D,N) \leftarrow \text{discretize}(\Delta,A,B)$
            \State $y \leftarrow \text{SSM}(\bar{A},\bar{B},C)(x)$ \par
            \Comment{Time-invariant: recurrence or convolution}
            \State \textbf{return} y
        \end{algorithmic}
    \end{algorithm}
\end{minipage}
\begin{minipage}{.48\textwidth}
    \begin{algorithm}[H]%
        \centering
        \caption{SSM+Selection(S6)}
        \begin{algorithmic}[1]
            \Input{$x:(B,L,D)}$
            \Output{$y:(B,L,D)$}
            \State $A:(D,N) \leftarrow \text{Parameter}$ \par \Comment{$\text{Represents structured}\ \ N \times N\ \ \text{martix}$}
            \State $B:\textcolor{red!90!black}{(B,L,N)} \leftarrow \textcolor{red!90!black}{s_B(x)}$ 
            \State $C:\textcolor{red!90!black}{(B,L,N)} \leftarrow \textcolor{red!90!black}{s_C(x)}$
            \State $\Delta:\textcolor{red!90!black}{(B,L,D)} \leftarrow \tau_\Delta(\text{Parameter}+\textcolor{red!90!black}{s_\Delta(x)})$
            \State $\bar{A},\bar{B}:(B,L,D,N) \leftarrow \text{discretize}(\Delta,A,B)$
            \State $y \leftarrow \text{SSM}(\bar{A},\bar{B},C)(x)$ \par
            \Comment{\textcolor{red!90!black}{Time-varying}: recurrence (\textcolor{red!90!black}{scan}) only}
            \State \textbf{return} y
        \end{algorithmic}
    \end{algorithm}
\end{minipage}
\vskip.5cm
\lipsum[2]
\end{document}

image.png

得到的效果有以上的问题

还有第四个问题:在minipage内部的\begin{algorithm}[H]为何一定是[H],而不能是[htbp]??后者提示报错。

查看更多

关注者
0
被浏览
440
1 个回答
泪过无痕
泪过无痕 2024-08-26
这家伙很懒,什么也没写!

我先捡个软柿子捏:[H]的意思是:就在这里!有这个说明你间接导入了float宏包,意思是,不管latex的换页算法,就在此处放入浮动体。这个选项一般用于给Word用惯了的老师交论文……

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览