【问题标题】:problem in not showing the statement after arrow inside if else statementif else 语句中箭头后不显示语句的问题
【发布时间】:2022-11-08 18:14:14
【问题描述】:

我在乳胶中编写了一个算法,如下所示。

\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{algorithm}
\caption{My algorithm}\label{euclid}
    ...
    \State $\vec{cle} \gets $\text{Mean($o1,o2$)}
                \If{$\vec{clh[t]}$ is empty}
                     \State $\vec{clh[t]} \gets $\vec{cle}$
                \Else
                     \State $\vec{$clh[t]} \gets \text{MeanCalc}($\vec{$cle}*0.1,clh[t]*0.5)$
                \EndIf
            \EndIf

我的问题是,在 If 语句之后的行中,$\vec{cle}$ 没有出现在箭头之后。在 else 之后, \State $\vec{$clh[t]} 也不会出现在箭头之前。如果有人可以帮助我,我将不胜感激

【问题讨论】:

  • 请提供您的编译输出...我想验证一些东西。

标签: latex overleaf


【解决方案1】:

您的 sn-p 中数学环境 $...$ 的使用不一致...

documentclass{article}
usepackage{algorithm}
usepackage{algpseudocode}
egin{document}
egin{algorithm}
caption{My Algorithm}label{alg:euclid}
egin{algorithmic}

State $ec{cle} gets $	ext{Mean($o1,o2$)}
    If{$ec{clh[t]}$ is empty}
        State $ec{clh[t]} gets ec{cle}$
    Else
        State $ec{clh[t]} gets $	ext{MeanCalc}($ec{cle}*0.1,clh[t]*0.5)$  
    EndIf
end{algorithmic}
end{algorithm}

end{document}

结果:

希望这可以帮助

【讨论】:

    猜你喜欢
    • 2021-05-15
    • 1970-01-01
    • 2014-09-26
    • 1970-01-01
    • 2013-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多