
預期輸出是
而且,我的輸出是
在我的輸出中Brancing
處於正確的位置。前 3 個項目應從 向右移動,Brancing
並應向右移動,以便與Bounding
對齊Brancing
。 如果與預期混淆。Bounding
微量元素
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{algpseudocode}
\usefonttheme[onlymath]{serif}
%this code is from: https://tex.stackexchange.com/a/353165/101651
\algnewcommand\algorithmicinput{\textbf{Input:}}
\algnewcommand\algorithmicoutput{\textbf{Output:}}
\algnewcommand\algorithmicinitialization{\textbf{Initialize:}}
\algnewcommand\Input{\item[\algorithmicinput]}%
\algnewcommand\Output{\item[\algorithmicoutput]}%
\algnewcommand\Initialize{\item[\algorithmicinitialization]}%
\begin{document}
\begin{frame}[fragile]
\begin{block}{BnB algorithm for QWSRM problem}
\begin{algorithmic}
\Input $\mathcal{Q}_{\text{init}}, \mathcal{A}, \text{and} \mathcal{f} \text{(c)}.$
\Initialize Obtain $c_{i} \text{ by solving } \frac{\delta f(c)}{\delta c_{i}}=0, \text{ for } i\in\mathcal{N}.\text{ Set } k = 1, \mathcal{B} = \mathcal{Q}_{init},u_{1}=\gamma_{ub}(\mathcal{Q}_{init}) \text{ and } l_{1} = \gamma_{lb}(\mathcal{Q}_{init}).$\\
Check the feasibility of problem (17) with given
\If{feasible}
\State $c_{0} = \widetilde{c};$
\Else
\While{$u_{k} - l_{k} > \epsilon$}
\State Branching:
\begin{itemize}
\item Set $\mathcal{Q}_{k} = \mathcal{Q}, \text{ where } \mathcal{Q} \text{ satisfies } \gamma_{lb}(\mathcal{Q}) = l_{k}.$
\item Split $\mathcal{Q} \text{ into } \mathcal{Q}_{\rm{I}} \text{ and } \mathcal{Q}_{\rm{II}}, \text{ along one of its longest edges.}$
\item Update $\mathcal{B}_{k+1} = (\mathcal{B}_{k}\setminus{\{\mathcal{Q}_{k}\}}) \bigcup (\mathcal{Q}_{\rm{I}}, \mathcal{Q}_{\rm{II}}).$
\end{itemize}
Bounding:
\begin{itemize}
\item Update $u_{k+1} = \min_{\mathcal{Q}\in\mathcal{B}_{k+1}}{\{\gamma_{ub}(\mathcal{Q})}\}$
\item Update $l_{k+1} = \min_{\mathcal{Q}\in\mathcal{B}_{k+1}}{\{\gamma_{lb}(\mathcal{Q})}\}$
\end{itemize}
\EndWhile\\
Set $c_{0} = c_{min};$
\EndIf
\Output $c_{0}.$
\end{algorithmic}
\end{block}
\end{frame}
\end{document}
答案1
若要將項目符號與「分支」對齊,您可以在沒有逐項環境的情況下手動插入項目符號:
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{algpseudocode}
\usefonttheme[onlymath]{serif}
\begin{document}
\begin{frame}[fragile]
\begin{block}{BnB algorithm for QWSRM problem}
\begin{algorithmic}
\State Branching:
\State\quad\usebeamertemplate{itemize item} Set $\mathcal{Q}$...
\State\quad\usebeamertemplate{itemize item} Split $\mathcal{Q}$...
\State Bounding:
\State\quad\usebeamertemplate{itemize item} Update $u_{k+1}$
\end{algorithmic}
\end{block}
\end{frame}
\end{document}