SYSU-SCC / sysu-thesis

中山大学 LaTeX 论文项目模板
GNU General Public License v3.0
558 stars 71 forks source link

If 语句在算法环境中报错 #76

Closed river7816 closed 1 year ago

river7816 commented 1 year ago

您好, 想请问一下如何解决if语句在算法环境中报错chap04.tex (line 240) Undefined control sequence. (^^I^^I\EndIf ...) 我在main.tex中添加了\usepackage{algorithmic}无法解决

image
river7816 commented 1 year ago
 \If{$i\geq 5$}{
            \State $i \gets i-1$
        } \Else {
             \If{$i\leq 3$}{
            \State  $i \gets i+2$}

        }

        }

我用{}好像还是没有得到我想要的结果, 要如何改正代码才能得到如下结果

if i>= 5:
    i -= 1
else:
    if i <= 3:
        i += 2
river7816 commented 1 year ago
    \If{$i\geq 5$}{
             $i \gets i-1$
        } \Else {
             \If{$i\leq 3$}{
                $i \gets i+2$}

        }

已解决,去掉\State即可