3

I am working on IEEE 2 column format and I wrote algorithm but the algorithm is not able to fix in the column as it has free space above and below the algorithm as shown in figure how to solve this issue

enter image description here

     \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}
0

2 Answers 2

4

The issue here is that the algorithm doesn't fit within the current column and is therefore pushed to the next one and since there's no text to float around, it centers the float within that column. Add more text and the float display should allow for the "proper" spacing/layout.

enter image description here

\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}
3
  • where you make changes in code just removed figure tag?
    – user12
    Commented Oct 4, 2021 at 19:33
  • 3
    @user12: The placement of a non-float (\begin{algorithm}[H]...\end{algorithm}) inside a float (\begin{figure}...\end{figure}) is not necessary, since you can just use \begin{algorithm}...\end{algorithm} (probably with the [t]op float specifier).
    – Werner
    Commented Oct 4, 2021 at 19:39
  • Thankyou so much you are amazing
    – user12
    Commented Oct 4, 2021 at 19:44
2

I heve a kind of solution but it is very manually figure placing and even not correct but it should work for You.

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

enter image description here

5
  • LaTeX Error: Unknown float option `r'. its giving error
    – user12
    Commented Oct 4, 2021 at 19:32
  • sorry, edited it is not r! it is p!, working? Commented Oct 4, 2021 at 19:35
  • its working in this example but when i put this in my paper the algorithm start from top of page even it covers the header space
    – user12
    Commented Oct 4, 2021 at 19:42
  • sorry but I tried in 2 different editors, must work Commented Oct 4, 2021 at 19:46
  • yes its working but when i included in my paper it didnt
    – user12
    Commented Oct 4, 2021 at 19:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .