![如何在算法输入中创建列表](https://linux22.com/image/343050/%E5%A6%82%E4%BD%95%E5%9C%A8%E7%AE%97%E6%B3%95%E8%BE%93%E5%85%A5%E4%B8%AD%E5%88%9B%E5%BB%BA%E5%88%97%E8%A1%A8.png)
我正在使用algorithm2e
包编写算法。我的输入描述有点长。我想将其组织成一个列表。我的文档有 2 列,所以我还需要输入列表与我的列宽对齐。我尝试了以下方法,但看起来有点混乱。
% 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}
这是我得到的输出:
答案1
有多种可能性;这完全取决于你想要什么。以下是一些可能性。
\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}
\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}%
}
\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}%
}
\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
}