与原文的最大差异是12pt的字体相对于版面太大了,改用默认的10pt并微调\item[]的定义即可:
\algnewcommand\algorithmicinput{\textbf{Input:}}
\algnewcommand\Input[1]{\item[\,\algorithmicinput]\ #1}
\algnewcommand\algorithmicoutput{\noindent\textbf{Output:}}
\algnewcommand\Output[1]{\item[\,\algorithmicoutput]\ #1}完整代码:
\documentclass[a4paper]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{algorithm}
\usepackage{algpseudocode}
\algnewcommand\algorithmicinput{\textbf{Input:}}
\algnewcommand\Input[1]{\item[\,\algorithmicinput]\ #1}
\algnewcommand\algorithmicoutput{\noindent\textbf{Output:}}
\algnewcommand\Output[1]{\item[\,\algorithmicoutput]\ #1}
\pagestyle{empty}
\begin{document}
\lipsum[1]
\medskip
\noindent\begin{minipage}{.49\textwidth}%
\begin{algorithm}[H]
\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}\hfill%
\begin{minipage}{.49\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}%
\medskip
\lipsum[2]
\end{document}





















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