两列中的算法不允许文本到侧面

两列中的算法不允许文本到侧面

我正在排版一个两列文档,其中有一个算法作为图表。算法在左列,但右列什么都没有,浪费空间。

我的工作示例是分享LaTeX

答案1

双栏文档中的浮动实际上并不起作用,也不会像作者希望的那样固定在栏上。因此,您通常需要做一些准备工作来按照自己的意愿调整。

下面我在代码中将第二个“浮点数”稍微推远一点,并使用以下方法延迟其输出afterpage。允许在设置第一页的所有滚动文本之前将其放入第二页。它被放置在一个内部minipage(以避免它全部浮动),底部有\strut类似开始和间隙。\intextsep

在此处输入图片描述

\documentclass[conference,compsoc]{IEEEtran}
\usepackage{showframe}
\usepackage{afterpage,caption}
\usepackage[noend]{algpseudocode}

% COMMANDS
% ========
\newcommand{\keyword}[1]{\emph{#1}}
\newcommand{\op}[1]{\mbox{\texttt{#1}}}
\newcommand{\const}[1]{\mbox{\textsc{#1}}}
\newcommand{\struct}[1]{\mbox{\textnormal{#1}}}
\newcommand{\membervar}[1]{\mbox{\textnormal{#1}}}
\newcommand{\typeattr}[1]{\emph{#1}}
\newcommand{\operator}[1]{\textbf{#1}}

\newcommand{\logt}[1]{\ensuremath{\log_2\left(\text{#1}\right)}}  % log base 2
\newcommand\AddressOf[1]{\operator{addressof} #1}
\newcommand\NewObj[2]{\operator{new} \struct{#1}(#2)}
\newcommand\LeftShift[2]{#1 \texttt{<\@<} #2}  % \@ to prevent latex from turning << into a different symbol
\newcommand\xor[2]{#1 \operator{xor} #2}
\newcommand\IsEq{\operator{is}}

\newcommand{\bigO}[1]{\ensuremath{\mathcal{O}(#1)}}

\algnewcommand\algorithmicclass{\textbf{Class}}
\algdef{SE}[CLASS]{Class}{EndClass}%
   [2]{\algorithmicclass\ \textproc{#1}}%
   {}%{\algorithmicend\ \algorithmicclass}%

\algnewcommand\algorithmicdestruct{\textbf{Destructor}}
\algdef{SE}[CLASS]{Destructor}{EndDestructor}%
   [2]{\algorithmicdestruct\ \textproc{#1}}%
   {}%{\algorithmicend\ \algorithmicdestruct}%

\algnewcommand\algorithmicconstruct{\textbf{Constructor}}
\algdef{SE}[CLASS]{Constructor}{EndConstructor}%
   [2]{\algorithmicconstruct\ \textproc{#1}}%
   {}%{\algorithmicend\ \algorithmicconstruct}%

% CONFIGURATION
% =============
\captionsetup{justification=justified}
\DeclareCaptionType{copyrightbox}

\setlength\intextsep{6pt}
\setlength\textfloatsep{6pt}



\begin{document}
\title{XXXX}

\author
{
  \IEEEauthorblockN
  {
    XXX
  }
  \IEEEauthorblockA
  {
    XXX
  }
}

\maketitle

% 99 words
\begin{abstract}
Taa aaaaaaaaaaa aa aaa-aaaaaaaa aaaa aa aaaaaaaaa; aaaaaaaaaa aaaa aaaaaa aaa aaaaaaaa aa aa aaaaaaaaa aa aaaaaa aaaaaa aaaaaaa aaaaaaaaaaa aaaaaaaaaa.
Aaaaaaaa aaaa aaaaaa aaaaaa aa a aaa-aaaaaaaa aaaaaaa aa aaaa aaaa aaaaaaaaaaa.
Taa aaa-aaaaaaaa aaaaaaaa aaaaaaaaaa aaaa aaaaaaaa aa aaaa aaaaaa aaa aaaaaaa aaaaaaaaa aa a aaaaaa aaaaaa aa aaaa.
Wa aaaaaaa a aaaaaaaaa aaaa aaaaaaaaaa aaaaaa aaaaaaaaaaa aaa aaaaaaaa aaaaaaaaa aaa aaaa aaaa aaaaaaa aaa aaaaaaaaa aa aaa aaaaaaaaa.
Taaa aaaaaaa aaa aaaaaa aaaaaaaa aa aaaaaaaaa aaa-aaaaaaaa aaaaaaaaaa.
Wa aaaa aaaaaaa a aaaaaaa aaaa aaaaaaaaaaaa aaa aaaa aaaa aaaaa aaa-aaaaaaaa aaaaaaaaaa aaa aa aaaaaaaaaaa aaaaa aaa aaaaaaaaa.
\end{abstract}


\subsection{Faaaaaaaa Saaaaaa}
Taaaaa aaaaaaaa a aaaaaa aa aaaaaaaa aaaaaaa aaa aaaaaaaaaa aa aaaaa a aaaaaaaaa aaa aa aaaaaaaaaaaa aaa-aaaaaaaa aa aaaa-aaaa aaaaaaaaaa.
Taa aaaaaaaaa aaaaaaa aaaaaaa aaaaaaaa aaaa aaaaa aaaa-aaaa aaaa aaaaaaaaaa aa aaaaaaaaaaa aa Taaaaa.
Taaaa aaaaaaaa aaaa aaaaaaaa aaaaaaa aaaa aaaaaaaa aaa aaaaaaaaaaaaaa, aaaaaaaaaaaaa, aaa aaaaaaaaaaa aa aaa  aaa aaaaaaaaa.


\begin{figure}[h]
\raggedright{}
\begin{algorithmic}[1]
\Class{aaaaaa$<$T$>$ aaaaaaa OaaaaaaaaRaaaaa}

  \State{aaaaaa Saaaa aaaaa;}
  \State{aaaaa T* aaaaaaaaa[];}
  \State{aaaaa T aaaaaaaa\_aaaaaa[];}
  \State{aaaaa T aaa\_aaaaaa[];}
  \State{aaaaa aaaaaa$<$AAaaAaaaaa*$>$ aaaaaaa[];}
\\
  \Destructor{AAAAaa}{}
      \For {aaaaa \textbf{aa} aaaaaaa}
        \State{RC::aaaaaaaaa::aaaaaa(a);}
      \EndFor{}
  \EndDestructor{}
\\
  \Function{aa\_aa\_aaaaaaa}{}
    \For {helper \textbf{aa} aaaaaaa}
      \If{RC::aa\_aaaaaaa(aaaaaa) == aaaa}
        \State{\Return{aaaa;}}
      \EndIf{}
    \EndFor{}
    \State{\Return{aaaaa;}}
  \EndFunction{}
\\
  \Function{aaaa\_aaaaaaaa}{$a=0$}
    \For{a$<$aaaaaaa.aaaaaa; a$++$}
      \If{aaaaa\_aaaaaa(a) == aaaaa}
        \State{\Return{aaaaa.aaaa(\null) == aaaa;}}
      \EndIf{}
    \EndFor{}
    \State{aaaaa.aaa(aaaaaaaaa, aaaa);}
    \State{\Return{aaaaa.aaaa(\null) == aaaa;}}
  \EndFunction{}
\EndClass{}
\end{algorithmic}
\caption{AAAA aaaaaaaaaa aaaaa}
\end{figure}

Taa aaaaaa aa aaa aaaa-aaaa Aaaaa-Waaa Caaaaaa-aaa-Saaa (AAAA)aaaa{aaaa} aaaa aaa aaaaa aa aaaaaaaaaa aaaaaaa.
Taaaa aaaaaa aaaaaaaaa aaa a aaaaaa aa aaaaa aaaaaa aaaaaaaaa aaa aaaaa aa Faaaaaaaa{aaa:aaaaaa} aaaaaa{aaa:aaaaaaaaaa}.
Aa AAAA aaaaaaaaa aa aaaaaaaaa aa aaaaaaaaaaa aaaaaaaaa aaa aaaaaaaa aaaaa aa aaaa aaaaaaa aaaa a aaaaaaaaa aa aa AAaaHaaaaa.
Ta aaaaaaa aaa ABA aaaaaaa aaaa aaaaaaaaa, aaaa aaaaaa aaaa aaa aaaaaaaaaaa aaaaa~(Saaaaaaaaa{aaa:aaaaaaaaaa}).
Aaaaa aaaaaaa aa AAaaHaaaaa, aaa aaaa aaaa aa aa aaaaaaaaa aa aaaa aaa AAaaOa.
Wa aaaaaaa aaa aaaaaaaaaaa aaaaa aa aaaaaaaa aa aa{aaaaaaaaa} aaaaaaaa~(Aaaaaaaaaaaa{aaa:aaaaaaaaaa} Laaaaaa{aaa:aaaaaaaaaa:aaaaa}.
Taaa aaaaaaaa aaaa a aa{aaa} aaaaaaaaa aa aaaaaa a aaaaa aaaaaaaaa aa aaa aaaaaaa aa aaa AAaaHaaaaa.
Ia aaaaaaa aaaaaaa aa aaa aaa aaaaa aaaaaaaaaa aaa AAaaHaaaaa.
Ia aa aaaaaaaaaa aaaa aaaaa AAaaHaaaaa, aaa aaaaaaaa aaaaaaa aaa AAaaHaaaaa.
Ia aa aaaaaaaaa aa aaaaaaa aaaaaa aaaaaaaaaaa aaaaaa aaaaaaa aa aaaaaaa aaaaa aaaaaaa aaaa aaaaaaaaa aaaa.

Aaaaaaaaaaaa{aaa:aaaaaaaaaa} Laaaaaa{aaa:aaaaaaaaaa:aaaaaaaa} aaaaaaaa aaa aaaaaaaa aaaaaaaa aaaa aa aaaaaa aa a aaaaaa aa aaaaaa aa AAaaHaaaaa aaaaaa aa a aaaaaaaaa aaaaaa.
Baaaaaa a aaaaaa aaaaa aaa aaaaaaaa aaaaaaaa aaaaa aa aaa aaaaaaaa a aaaaa aa aaa aaaaaa, aa aaaa aaa aaaa aa aaaaaaaa aaa aaaa aaaaa a aaaaaaaaaa aaa aaaa aaaaaa aa aaaaa.
Faa aaaaaaa, aa aa AAaaHaaaaa aaa aaaaaa aa aaaaa, aaa aa\_aaaaa aaaaaaaa (aaaaa aa aaaaaa aa aaa aaaaa aaaaaaaa) aaaaa aaaa aaaaaaa aa aaaa aaa aaaa aa aaaaaaaaa aaaaaaaa aaaaa.

\afterpage{%
\noindent\begin{minipage}{\columnwidth}
\begin{algorithmic}[1]
\Class{AAaaAaaaaa aaaaaaa Daaaaaaaaa\rule{0pt}{\baselineskip}}

  \State{aaaaa AAAAaa aa;}
  \State{aaaaa aaa aaa;}
\\
  \Function{aa\_aaaaa}{aaaaaaa, aaa}
    \If{AA::aaaaa(AA::aaaa::aaaa, aaaaaaa, aaa, aa)}
      \State{aaaa aaa = aaaa.aaaaaaaaa(\null);}
      \If{aaa == aaaaa}
        \State{aaaaaaa.aaa(aaa, aa.aaaaaaaa\_aaaaaa[aaa]));}
      \EndIf{}
      \State{AA::aaaaaaa(AA::aaaa::aaaa);}
      \State{\Return{aaa;}}
    \EndIf{}
    \State{\Return{aaaaa;}}
  \EndFunction
\\
  \Function{aaaaaaaa}{aaaaaaa, aaa}
    \State{aa.aaaa\_aaaaaaaa(aaa+1);}
    \If{aa.aaaaa == aaaaaa}
      \State{aaaa = aa.aaa\_aaaaaa[aaa];}
    \Else{}
      \State{aaaa = aa.aaaaaaaa\_aaaaaa[aaa];}
    \EndIf{}
    \State{aaaaaaa.aaa(aaa,aaaa}
    \State{\Return{aaaaaaa.aaaa();}}
  \EndFunction{}
\\
  \Function{aaaaa}{\null}
    \If{aa.aaaaa == aaaaaa}
      \State{\Return{aa.aaa\_aaaaaa[aaa];}}
    \Else{}
      \State{\Return{aa.aaaaaaaa\_aaaaaa[aaa];}}
    \EndIf{}
  \EndFunction{}
\\
  \Function{aaaaaaaaa}{\null}
    \State{aa.aaaaaaa[aaa].aaa(aaaa,aaaa)}
    \If{aa.aaaaaaa[aaa].aaaa(\null) $\neq$ aaaa}
      \State{aa.aaaaaaaaa[aaa].aaa(aaaa, aa.aaaaaaaa\_aaaaaa[aax]);}
      \State{\Return aaaaa;}
    \EndIf{}
    \State{\Return{aaaa;}}
  \EndFunction{}
\EndClass{}
\end{algorithmic}
\captionof{figure}{aaaa aaaaaaaa aaaaaa}
\end{minipage}\par
\vspace{\intextsep}
}

Ia aaaaa aaa aa AAaaHaaaaa aa aa aaaaaaa, aaa AAAA aaaaaaaaa aaaa aaaaaa aa aaaa aa aaaaaaaaa.
Taaa aa aaaaaaaaaaaa aa aaaaaaa aaa AAAAaa'a aaaa\_aaaaaaaa aaaaaaaa.
Uaaa aaa aaaaaa, aaa aaaaa aa aaa AAAAaa aaaa aaaa aaaa aaaaaaa aaaa aaaaaaaaa aa aaaaaa aaaaaa aa aaaaaa.
Oaaa aaa aaaaa aaa aaaa aaaaaaa, aaa AAaaHaaaaaa aaa aa aaaaaaaa aaaa aaaaa aaaaaaa aaaaaa.
Taa aaaaaaa aaaaa aa aa AAaaHaaaaa aa aaaaaaaaaa aa aaaaaaa aaaaa aaaa{aaaaa} aaaaaaaa.

Oaa AAAA aaaaaaaaaaaaaa aaaa Taaaaa'a aaaaaa aaaaaaaaaa aaaaaaaa aa aaaaaaaaa aaa aaaaaaaaaaa aa aaaaaaaaaa aaaaaaa.
Wa aaa aaaaaa aaaaaaaa aa aaaaaaa AAAAaa aaaaaaa aaa aaaaaaaaa aaaaaaaa aa aaaaaaa AAaaHaaaaa aaaaaaa.
Taa AAAAaa aaaaaa aa aaaaaaaaaaa aaa aaaaaaa aaa AAaaHaaaaa aaaaaaa aaaaaaaaaa aa aa.
Aa aaaa, aaa aaaaaa aaaa aaaa aaa AAAAaa aaaa aaaaaaaa aaaaaaaaa aa aaaaa AAaaHaaaaaa.
Taaa aaaaaaaaa aa aaaaaaaaa aa aaa AAAAaa'a  aa{aa\_aa\_aaaaaaa} aaa aaaaaaaaaa aaaaaaaaa.

\subsection{Faaaaaaaa Saaaaaa}
Taaaaa aaaaaaaa a aaaaaa aa aaaaaaaa aaaaaaa aaa aaaaaaaaaa aa aaaaa a aaaaaaaaa aaa aa aaaaaaaaaaaa aaa-aaaaaaaa aa aaaa-aaaa aaaaaaaaaa.
Taa aaaaaaaaa aaaaaaa aaaaaaa aaaaaaaa aaaa aaaaa aaaa-aaaa aaaa aaaaaaaaaa aa aaaaaaaaaaa aa Taaaaa.
Taaaa aaaaaaaa aaaa aaaaaaaa aaaaaaa aaaa aaaaaaaa aaa aaaaaaaaaaaaaa, aaaaaaaaaaaaa, aaa aaaaaaaaaaa aa aaa  aaa aaaaaaaaa.
Aaaaaaaaaaaa{aaa:aaaaaaaaaa} Laaaaaa{aaa:aaaaaaaaaa:aaaaaaaa} aaaaaaaa aaa aaaaaaaa aaaaaaaa aaaa aa aaaaaa aa a aaaaaa aa aaaaaa aa AAaaHaaaaa aaaaaa aa a aaaaaaaaa aaaaaa.
Baaaaaa a aaaaaa aaaaa aaa aaaaaaaa aaaaaaaa aaaaa aa aaa aaaaaaaa a aaaaa aa aaa aaaaaa, aa aaaa aaa aaaa aa aaaaaaaa aaa aaaa aaaaa a aaaaaaaaaa aaa aaaa aaaaaa aa aaaaa.
Faa aaaaaaa, aa aa AAaaHaaaaa aaa aaaaaa aa aaaaa, aaa aa\_aaaaa aaaaaaaa (aaaaa aa aaaaaa aa aaa aaaaa aaaaaaaa) aaaaa aaaa aaaaaaa aa aaaa aaa aaaa aa aaaaaaaaa aaaaaaaa aaaaa.

Ia aaaaa aaa aa AAaaHaaaaa aa aa aaaaaaa, aaa AAAA aaaaaaaaa aaaa aaaaaa aa aaaa aa aaaaaaaaa.
Taaa aa aaaaaaaaaaaa aa aaaaaaa aaa AAAAaa'a aaaa\_aaaaaaaa aaaaaaaa.
Uaaa aaa aaaaaa, aaa aaaaa aa aaa AAAAaa aaaa aaaa aaaa aaaaaaa aaaa aaaaaaaaa aa aaaaaa aaaaaa aa aaaaaa.
Oaaa aaa aaaaa aaa aaaa aaaaaaa, aaa AAaaHaaaaaa aaa aa aaaaaaaa aaaa aaaaa aaaaaaa aaaaaa.
Taa aaaaaaa aaaaa aa aa AAaaHaaaaa aa aaaaaaaaaa aa aaaaaaa aaaaa aaaa{aaaaa} aaaaaaaa.

\end{document}

答案2

您的算法浮动在figure环境中,无论内容的宽度如何,该环境都会填充两列。要将算法限制在一列,请将其更改为环境figure*

相关内容