gpt4 book ai didi

latex - 使用 LaTeX 使算法更具可读性

转载 作者:行者123 更新时间:2023-12-01 07:42:13 30 4
gpt4 key购买 nike

我试图让我的算法在 LaTeX 中更具可读性:

\documentclass{IEEEtran}

\usepackage{algpseudocode}
\usepackage{algorithm}

\begin{document}

\begin{algorithm}[H]
\caption{Detecta \textit{Slowloris}}
\begin{algorithmic}[1]

\Function{Divide\_slices\_1min }{Arquivo PCAP}
\State \Return \textit{sliceAtual}
\EndFunction
\Function{Separa\_IP\_Origem\_Destino}{sliceAtual}
\State \Return $ArquivoIPs$
\EndFunction
\Function{Calcula\_entropia\_IP\_Origem\_Destino}{ArquivoIP}
\State \Return $EntroSliceAtualIP$
\EndFunction
\Function{PVS}{sliceAtual}
\State \Return $PVS_SliceAtual$
\EndFunction

\Function{FCS}{sliceAtual}
\State \Return $FCS_SliceAtual$
\EndFunction

\If {$entropiaSliceAtual$ > $entropiaSemAtaq$ + 0,10*$entropiaSemAtaq$}
\If {$PVS_SliceAtual$ > $PVS_SemAtaq$ + 0.60*$PVS_SemAtaq$}
\If {$FCS_SliceAtual$ > $FCS_SemAtaq$ - 0.40*$FCS_SemAtaq$}

\State \Return $Ataque$
\Else
\State \Return $SemAtaques$
\EndIf
\EndIf
\EndIf

\end{algorithmic}
\end{algorithm}
\end{document}

结果不太好:

enter image description here

我希望它只出现在没有很多 endif 的函数调用中。

我想要这样的东西:

I would like something like this

有什么建议吗?我在努力!
IEEEtran 类是: https://ctan.org/pkg/ieeetran?lang=en

最佳答案

— So you just want to remove the 3 end ifs?
— Yes, all "ends": end if , end function.



如果是这样,你只需要更换

\usepackage{algpseudocode}



\usepackage[noend]{algpseudocode}

资料来源:
  • algorithmics.pdf中的第3.1.9段
  • 第 66-74 行在 algpseudocode.sty
  • 关于latex - 使用 LaTeX 使算法更具可读性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48116170/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com