我正在尝试使用 Algorithm2e 包格式化伪代码。所需输出具有以下格式: 下面是我尝试格式化该伪代码的代码:
\usepackage[ruled,vlined]{algorithm2e}
\begin{algorithm}[H]
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\SetKwInOut{Parameters}{Parameters}
\SetKwInOut{Procedure}{Procedure}
\textbf{Input:} \\
\qquad$\bullet$ An Oracle operator effecting the transformation $\ket{x}\ket{q}\rightarrow\ket{x}\ket{q\oplus f(x)}$\\
\textbf{Output:}\\
\qquad$\bullet$ The unique bit string x satisfying Eq. (32)\\
\textbf{Procedure:}\\
\qquad$\bullet$\ \textbf{Step 1:} Perform state initialization\\
\qquad$\bullet$\ \textbf{Step 2:} Apply Grover operator
\caption{Grover's Algorithm}
\end{algorithm}
我想知道是否有办法让文本/方程式bullet
在新行开始时不“超出”该点。谢谢!
答案1
使用enumerate
:
\begin{itemize}\setlength\itemsep{.5em}
\item[\textbf{Input:}]
\item An Oracle operator effecting the transformation $ \left| x\right\rangle\left| q\right\rangle\rightarrow\left| x\right\rangle\left| q\oplus f(x)\right\rangle$.
\item[\textbf{Output:}]
\item The unique bit string x satisfying Eq. (32)
\item[\textbf{Procedure:}]
\end{itemize}
\begin{enumerate}\setlength\itemsep{-.2em}\renewcommand{\labelenumi}{\bfseries Step \arabic{enumi}:}
\item Perform state initialization
\item Apply Grover operator
\item ??
\item profit
\end{enumerate}