如何调整算法和论文正文之间的间距?

如何调整算法和论文正文之间的间距?

我正在编写一些算法如下:

We describe some algorithms as follow:
\begin{figure*}[htbp]
\begin{minipage}[t]{.49\textwidth}
\begin{algorithm}[H]
\renewcommand{\thealgorithm}{}
\begin{algorithmic}[1]
\caption{$A_{1}\left( x_{1} \right)$}
\STATE $y_{1} \leftarrow f\left( x_{1} \right)$
\RETURN $y_{1}$
\end{algorithmic}
\end{algorithm}
\end{minipage}
\hfill
\begin{minipage}[t]{.49\textwidth}
\begin{algorithm}[H]
\renewcommand{\thealgorithm}{}
\begin{algorithmic}[1]
\caption{$A_{2}\left( x_{2} \right)$}
\STATE $y_{2} \leftarrow f\left( x_{2} \right)$
\RETURN $y_{2}$
\end{algorithmic}
\end{algorithm}
\end{minipage}
\end{figure*}

Blah, blah, blah...

然后它看起来如下:

在此处输入图片描述

论文正文和算法之间的间距太大,如何调整。

答案1

更改intextsep长度

\documentclass{article}

\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\setlength{\intextsep}{2pt}

\begin{document}

We describe some algorithms as follow:
\begin{figure*}[htbp]
  \begin{minipage}[t]{.49\textwidth}
    \begin{algorithm}[H]
      \renewcommand{\thealgorithm}{}
      \begin{algorithmic}[1]
        \caption{$A_{1}\left( x_{1} \right)$}
        \State $y_{1} \leftarrow f\left( x_{1} \right)$
        \Return $y_{1}$
      \end{algorithmic}
    \end{algorithm}
  \end{minipage}
  \hfill
  \begin{minipage}[t]{.49\textwidth}
    \begin{algorithm}[H]
      \renewcommand{\thealgorithm}{}
      \begin{algorithmic}[1]
        \caption{$A_{2}\left( x_{2} \right)$}
        \State $y_{2} \leftarrow f\left( x_{2} \right)$
        \Return $y_{2}$
      \end{algorithmic}
    \end{algorithm}
  \end{minipage}
\end{figure*}

Blah, blah, blah...

\end{document}

在此处输入图片描述

相关内容