0

My last page of an article is similar to the one below.
On the second column, the fig. 4 is not placed on the top and the algorithm is not placed just below the fig. 4.
How can I fix this? The figure and algorithm are not quite related so I don't want to put them in the same float.
I believe that if I add text (or many lines of text) then it will work but I want to ensure they're not centered even when there is no text or litte text.

The solution here work for figure but not the algorithm.

\makeatletter
\setlength{\@fptop}{0pt}
\makeatother

enter image description here

\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{array}
\usepackage{lipsum}
\usepackage{algorithm}
\usepackage{algpseudocode}

\usepackage{amsmath}
\newcolumntype{L}{>{$}l<{$}}
\newcommand\cpair[2]{%
\begin{tabular}{LL}#1 & #2\end{tabular}}
\algrenewcommand{\algorithmiccomment}[1]{\hfill#1}

\begin{document}

\begin{figure}[!t]
    \centering
    \includegraphics[width=\linewidth]{example-image-a}
    \caption{a caption}
    \label{fig:a label}
\end{figure}

\begin{figure}[!t]
    \centering
    \includegraphics[width=\linewidth]{example-image-b}
    \caption{a caption}
    \label{fig:a label}
\end{figure}

\begin{figure}[!t]
    \centering
    \includegraphics[width=\linewidth]{example-image-c}
    \caption{a caption}
    \label{fig:a label}
\end{figure}

\begin{figure}[!t]
    \centering
    \includegraphics[width=\linewidth]{example-image}
    \caption{a caption}
    \label{fig:a label}
\end{figure}

\begin{algorithm}
\caption{Insertion-Sort køretid}\label{AlgRun}
\begin{algorithmic}[1]
    \Procedure{insertion-sort}{$A,n$}   \Comment \cpair{c_1}{n=0}
        \State $inversions = 0$         \Comment \cpair{c_1}{n=1}
        \State \textit{L}[0..\textit{n} - 1] be a new array.
        \For{q=0}{n-1}
            \State L[q] = A[q]
        \EndFor
        \For{j=1}{n-1}
            \State $key = L[j]$
            \State $i = j - 1$
            \While{$ i \geq 0$ \textbf{and} $L[i] > key$}
                \State L[ i + 1] = L[ i ]
                \State $j = i - 1$
                \State $inversions = inversions + 1$
            \EndWhile
            $L[i + 1] = key$
        \EndFor
        \Return{inversions}
    \EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}

1 Answer 1

1

The documentation for the IEEEtran document class discusess balancing the columns of the last page in section XIV (page 16). It suggests some workarounds.

One of them it mentions is using \enlargethispage with a negative value.

In your sample document, putting something like \enlargethispage{-0.2in} anywhere prior to \begin{algorithm} seems to have the desired effect.

balancing figures with IEEEtran

Because your actual document probably uses different figures, etc., and is different in other ways, you may have to play around with different dimensions for the command, and different placements.

0

You must log in to answer this question.

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