如何修复算法前后的空间

如何修复算法前后的空间

我正在研究 IEEE 2 列格式,我编写了算法,但该算法无法在列中修复,因为它在算法的上方和下方都有可用空间,如图所示,如何解决这个问题

在此处输入图片描述

     \documentclass[conference]{IEEEtran}
     \IEEEoverridecommandlockouts
     \usepackage{cite}
     \usepackage{amsmath,amssymb,amsfonts}
     \usepackage{algorithmic}
     \usepackage{graphicx}
     \usepackage{textcomp}
     \usepackage{xcolor}
     \usepackage{subfig}
     \usepackage[english]{babel}
     \usepackage[utf8]{inputenc}
     \usepackage{makecell}%
     %table
     \usepackage[margin=1in]{geometry}
     \usepackage{tabularx,booktabs}
     \newcolumntype{Y}{ {\centering\arraybackslash}X}
     \usepackage{blindtext}
     \usepackage{times}
     %\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
     \usepackage{algorithm} 
     %\usepackage{algpseudocode} 
      \usepackage{algorithmic}
     
     \makeatletter
     \newcommand{\removelatexerror}{\let\@latex@error\@gobble}
     \makeatother
     
     %\documentclass{IEEEtran}
     
     \usepackage[english]{babel}
     \usepackage[utf8]{inputenc}
     \def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
         T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
         
     \begin{document}
     Thermodynamics is a branch of physics that deals with heat, work, and temperature, and their relation to energy, radiation, and physical
      properties of matter. The behavior of these quantities is governed by
      the four laws of thermodynamics which convey a quantitative
      description using measurable macroscopic physical quantities, but may
      be explained in terms of microscopic constituents by statistical
      mechanics. Thermodynamics applies to a wide variety of topics in
      science and engineering, especially physical chemistry, biochemistry,
      chemical engineering and mechanical engineering, but also in other
      complex fields such as meteorology.
     
     Historically, thermodynamics developed out of a desire to increase the efficiency of early steam engines, particularly through the work
      of French physicist Nicolas Léonard Sadi Carnot (1824) who believed
      that engine efficiency was the key that could help France win the
      Napoleonic Wars.[1] Scots-Irish physicist Lord Kelvin was the first to
      formulate a concise definition of thermodynamics in 1854[2] which
      stated, "Thermo-dynamics is the subject of the relation of heat to
      forces acting between contiguous parts of bodies, and the relation of
      heat to electrical agency."
     
     The initial application of thermodynamics to mechanical heat engines was quickly extended to the study of chemical compounds and
      chemical reactions. Chemical thermodynamics studies the nature of the
      role of entropy in the process of chemical reactions and has provided
      the bulk of expansion and knowledge of the
     
     \begin{figure}
     \begin{algorithm}[H]
      \caption{Algorithm}
      \begin{algorithmic}[1]
      \renewcommand{\algorithmicrequire}{\textbf{Input:}}
      \renewcommand{\algorithmicensure}{\textbf{Output:}}
      \REQUIRE {cells \(K =\{1, 2, \dots, n\}\)}
      \ENSURE  { vvvv}
      \\ \textit{bbbb} 
        \FOR  {$t=1,2,\ldots,T$}
        \STATE  hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh; 
          \FOR{ $f$  \(i\in n\) in $parallel$} 
               
          \ENDFOR
          \FOR{ $f$ \(i\in k\) in $parallel$} 
               
          \ENDFOR
     
     \textit{333333333333333}   
     \STATE ggggggggggggggggggggggggggggggggggggggggggggggggggggg
             \FOR{ $n$  }  
               \STATE  bbb 
               \STATE   bbbb
             \ENDFOR
     \STATE vvvvvvvvvvvvvvvv
     \textit{bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}   
     \STATE nnnnnnnnnnnnnnnn
     \STATE ggggggggggggggggggggggggggggg
     \STATE nnnnnnnnnnnnnnnn
     \STATE ggggggggggggggggggggggggggggg
     \STATE ggggggggggggggggggggggggggggg
     \STATE ggggggggggggggggggggggggggggg
     \STATE ggggggggggggggggggggggggggggg
     \FOR {bbbbbbbb}
     \STATE bbbbbbbbbbb
     \ENDFOR
     \FOR {bbbbbbbbb}
     \STATE nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
    \ENDFOR
    \ENDFOR 
    \RETURN bbb
    \end{algorithmic}
    \end{algorithm}
    \end{figure}
    \end{document}

答案1

这里的问题是,无法algorithm容纳在当前列中,因此被推到下一列,由于没有文本可以浮动,因此它将浮动置于该列的中心。添加更多文本,浮动显示应该允许“正确”的间距/布局。

在此处输入图片描述

\documentclass[conference]{IEEEtran}

\IEEEoverridecommandlockouts

\usepackage[margin=1in]{geometry}
\usepackage{newtxtext}
\usepackage{algorithm} 
\usepackage{algorithmic}
\usepackage[utf8]{inputenc}
   
\begin{document}

Thermodynamics is a branch of physics that deals with heat, work, and 
temperature, and their relation to energy, radiation, and physical
properties of matter. The behavior of these quantities is governed by
the four laws of thermodynamics which convey a quantitative
description using measurable macroscopic physical quantities, but may
be explained in terms of microscopic constituents by statistical
mechanics. Thermodynamics applies to a wide variety of topics in
science and engineering, especially physical chemistry, biochemistry,
chemical engineering and mechanical engineering, but also in other
complex fields such as meteorology.

Historically, thermodynamics developed out of a desire to increase the 
efficiency of early steam engines, particularly through the work
of French physicist Nicolas Léonard Sadi Carnot (1824) who believed
that engine efficiency was the key that could help France win the
Napoleonic Wars.[1] Scots-Irish physicist Lord Kelvin was the first to
formulate a concise definition of thermodynamics in 1854[2] which
stated, "Thermo-dynamics is the subject of the relation of heat to
forces acting between contiguous parts of bodies, and the relation of
heat to electrical agency."

The initial application of thermodynamics to mechanical heat engines was 
quickly extended to the study of chemical compounds and
chemical reactions. Chemical thermodynamics studies the nature of the
role of entropy in the process of chemical reactions and has provided
the bulk of expansion and knowledge of the

\begin{algorithm}[t]
  \caption{Algorithm}
  \begin{algorithmic}[1]
    \renewcommand{\algorithmicrequire}{\textbf{Input:}}
    \renewcommand{\algorithmicensure}{\textbf{Output:}}
    \REQUIRE {cells \(K =\{1, 2, \dots, n\}\)}
    \ENSURE  {vvvv}
    \\ \textit{bbbb} 
      \FOR  {$t=1,2,\ldots,T$}
      \STATE  hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh; 
        \FOR{ $f$  \(i\in n\) in $parallel$} 
          \STATE Something
        \ENDFOR
        \FOR{ $f$ \(i\in k\) in $parallel$} 
          \STATE Something
        \ENDFOR

    \textit{333333333333333}   
    \STATE ggggggggggggggggggggggggggggggggg
    \FOR{ $n$  }  
      \STATE bbb 
      \STATE bbbb
    \ENDFOR
    \STATE vvvvvvvvvvvvvvvv
    \textit{bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}   
    \STATE nnnnnnnnnnnnnnnn
    \STATE ggggggggggggggggggggggggggggg
    \STATE nnnnnnnnnnnnnnnn
    \STATE ggggggggggggggggggggggggggggg
    \STATE ggggggggggggggggggggggggggggg
    \STATE ggggggggggggggggggggggggggggg
    \STATE ggggggggggggggggggggggggggggg
    \FOR {bbbbbbbb}
      \STATE bbbbbbbbbbb
    \ENDFOR
    \FOR {bbbbbbbbb}
      \STATE nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
    \ENDFOR
    \ENDFOR 
    \RETURN bbb
  \end{algorithmic}
\end{algorithm}

Thermodynamics is a branch of physics that deals with heat, work, and 
temperature, and their relation to energy, radiation, and physical
properties of matter. The behavior of these quantities is governed by
the four laws of thermodynamics which convey a quantitative
description using measurable macroscopic physical quantities, but may
be explained in terms of microscopic constituents by statistical
mechanics. Thermodynamics applies to a wide variety of topics in
science and engineering, especially physical chemistry, biochemistry,
chemical engineering and mechanical engineering, but also in other
complex fields such as meteorology.

Historically, thermodynamics developed out of a desire to increase the 
efficiency of early steam engines, particularly through the work
of French physicist Nicolas Léonard Sadi Carnot (1824) who believed
that engine efficiency was the key that could help France win the
Napoleonic Wars.[1] Scots-Irish physicist Lord Kelvin was the first to
formulate a concise definition of thermodynamics in 1854[2] which
stated, "Thermo-dynamics is the subject of the relation of heat to
forces acting between contiguous parts of bodies, and the relation of
heat to electrical agency."

The initial application of thermodynamics to mechanical heat engines was 
quickly extended to the study of chemical compounds and
chemical reactions. Chemical thermodynamics studies the nature of the
role of entropy in the process of chemical reactions and has provided
the bulk of expansion and knowledge of the

Thermodynamics is a branch of physics that deals with heat, work, and 
temperature, and their relation to energy, radiation, and physical
properties of matter. The behavior of these quantities is governed by
the four laws of thermodynamics which convey a quantitative
description using measurable macroscopic physical quantities, but may
be explained in terms of microscopic constituents by statistical
mechanics. Thermodynamics applies to a wide variety of topics in
science and engineering, especially physical chemistry, biochemistry,
chemical engineering and mechanical engineering, but also in other
complex fields such as meteorology.

Historically, thermodynamics developed out of a desire to increase the 
efficiency of early steam engines, particularly through the work
of French physicist Nicolas Léonard Sadi Carnot (1824) who believed
that engine efficiency was the key that could help France win the
Napoleonic Wars.[1] Scots-Irish physicist Lord Kelvin was the first to
formulate a concise definition of thermodynamics in 1854[2] which
stated, "Thermo-dynamics is the subject of the relation of heat to
forces acting between contiguous parts of bodies, and the relation of
heat to electrical agency."

The initial application of thermodynamics to mechanical heat engines was 
quickly extended to the study of chemical compounds and
chemical reactions. Chemical thermodynamics studies the nature of the
role of entropy in the process of chemical reactions and has provided
the bulk of expansion and knowledge of the

\end{document}

答案2

我有一种解决方案,但它是非常手动的数字放置,甚至不正确,但它应该对你有用。

\begin{figure}        -->      \begin{figure}[p!]
                      -->      \vspace{-10cm}
\begin{algorithm}[H]  -->      \begin{algorithm}[H]

在此处输入图片描述

相关内容