LaTeX在线

常用

记得在两边加上$$(好像只有在Word插件Aurora中需要这么做)

符号 LaTeX代码 符号表示
小于号 \textless​ <
分数 \frac{}{}​ $\frac{}{}$
根号 \sqrt{} $$\sqrt{}$$
小空格 \+空格 -$$\ $$-
长空格 \quad -$$\quad$$-
章节符号 \S3.1 $$\S3.1$$

在Latex中使用algorithm2e显示if-elseif-else-endif

例子

  • 算法伪代码:

    使用Aurora+Algorithm2e在word中输入伪代码

    效果:

    image-20230423174821835

    实例代码:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    \begin{algorithm}[H]
    \KwData{cWnd, sSthresh}
    \KwResult{How does the Congestion Window of sender change}
    initialization of cWnd and sSthresh\;
    \While{running}{
    \If{Receivied an ACK}{
    \eIf{cWnd \textless sSthresh}{
    cWnd+=MSS; (Slow Start)
    }{
    cWnd+=$\frac{MSS}{cWnd}$; (Congestion Avoidance)
    }
    }
    \If{Encountered a loss}{
    \eIf{cWnd \textless sSthresh}{
    cWnd+=MSS; (Slow Start)
    }{
    cWnd+=$\frac{MSS}{cWnd}$; (Congestion Avoidance)
    }
    }
    }
    \caption{TCP Tahoe}
    \end{algorithm}

    效果:

    image-20230424175058122

    实例代码:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    \begin{algorithm}[H]
    \KwData{cWnd, RTT, $\alpha$, $\beta$}
    \KwResult{How does the Congestion Window of sender change}
    initialization of cWnd and estimation of baseRTT\;
    \While{running}{
    \If{A RTT passed}{
    \uIf{$ (\frac{cWnd}{RTT_{min}} -\frac{cWnd}{RTT} )\times RTT_{min}\textless \alpha $}{
    cWnd+=MSS;
    }
    \ElseIf{$(\frac{cWnd}{RTT_{min}} -\frac{cWnd}{RTT} )\times RTT_{min}\textgreater \beta$}{
    cWnd-=MSS;
    }
    }
    \If{Encountered a loss}{
    cWnd = $\frac{7}{8}$ cWnd;
    }
    }
    \caption{TCP Vegas}
    \end{algorithm}