5

I am using algorithm2e package to write an algorithm. I have somewhat long input description. I want to organize it in a list. My document is 2 column so I also need the input list to be alighed with my column width. I tried the following but it looks missy.

% This version uses the latex2e styles, not the very ancient 2.09 stuff.
\documentclass[letterpaper,twocolumn,10pt]{article}
\usepackage[]{algorithm2e}
\begin{document}



\begin{algorithm}[]

 \SetKwData{Left}{left}\SetKwData{This}{this}\SetKwData{Up}{up}
 \SetKwFunction{Union}{Union}\SetKwFunction{FindCompress}{FindCompress}
 \SetKwInOut{Input}{input}\SetKwInOut{Output}{output}

 \Input{ 

    \begin{itemize} 
        \item [($a_i,b_i$),($a_{i+1},b_{i+1}$),..etc.] list of tuples for start-end etc etc etc etc etc etc etc etc 
        \item [($c_i,d_i$),($c_{i+1},d_{i+1}$),..etc.] list of tuples for start-end etc etc etc etc etc etc etc etc
    \end{itemize}

}
 \Output{A partition of the bitmap}
 \BlankLine

 initialization\;
 \While{not at end of this document}{
  read current\;
  \eIf{understand}{
   go to next section\;
   current section becomes this one\;
   }{
   go back to the beginning of current section\;
  }
 }
 \caption{How to write algorithms}
\end{algorithm}

\end{document}

This is the output I get:

enter image description here

1 Answer 1

3

There are different possibilities; it all depends on what you want. Here are some possibilities.

\documentclass[letterpaper,twocolumn,10pt]{article}
\usepackage{algorithm2e}
\begin{document}
\begin{algorithm}[]
 \SetKwData{Left}{left}\SetKwData{This}{this}\SetKwData{Up}{up}%
 \SetKwFunction{Union}{Union}\SetKwFunction{FindCompress}{FindCompress}%
 \SetKwInOut{Input}{input}\SetKwInOut{Output}{output}%
 \Input
  {\begin{minipage}[t]{6cm}%
     \strut
     $(a_i,b_i)$, $(a_{i+1},b_{i+1})$, \dots\ tuples for
     start-end etc etc etc etc etc etc etc etc

     $(c_i,d_i)$, $(c_{i+1},d_{i+1})$, \dots\ tuples for
     start-end etc etc etc etc etc etc etc etc
     \strut
   \end{minipage}%
  }
 \Output{A partition of the bitmap}
 \BlankLine
 initialization\;
 \While{not at end of this document}%
   {read current\;
    \eIf{understand}%
      {go to next section\;
       current section becomes this one\;
      }%
      {go back to the beginning of current section\;
      }
   }
\caption{How to write algorithms}
\end{algorithm}
\end{document}

enter image description here

 \Input
  {\begin{itemize}
   \item $(a_i,b_i)$, $(a_{i+1},b_{i+1})$, \dots\ tuples for
     start-end etc etc etc etc etc etc etc etc
   \item $(c_i,d_i)$, $(c_{i+1},d_{i+1})$, \dots\ tuples for
     start-end etc etc etc etc etc etc etc etc
   \end{itemize}%
  }

enter image description here

 \Input
  {\begin{itemize}
   \item[] $(a_i,b_i)$, $(a_{i+1},b_{i+1})$, \dots\ tuples for
     start-end etc etc etc etc etc etc etc etc
   \item[] $(c_i,d_i)$, $(c_{i+1},d_{i+1})$, \dots\ tuples for
     start-end etc etc etc etc etc etc etc etc
   \end{itemize}%
  }

enter image description here

 \Input
  {\par
   $(a_i,b_i)$, $(a_{i+1},b_{i+1})$, \dots\ tuples for
     start-end etc etc etc etc etc etc etc etc
   \par
   $(c_i,d_i)$, $(c_{i+1},d_{i+1})$, \dots\ tuples for
     start-end etc etc etc etc etc etc etc etc
  }

enter image description here

You must log in to answer this question.

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