如何在投影仪的算法中缩进/对齐线?

如何在投影仪的算法中缩进/对齐线?

预期输出为

在此处输入图片描述

我的输出是

在此处输入图片描述

在我的输出中,Brancing位于正确位置。前 3 个项目应从 向右移动,Brancing并且Bounding应向右移动,以便与 对齐Brancing。第二 3 个项目应从 的新位置向右移动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

为了将项目符号与“分支”对齐,您可以手动插入项目符号,而无需使用 itemize 环境:

\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}

在此处输入图片描述

相关内容