Monday, January 15, 2018

Making an algorithm more readable using LaTeX

Leave a Comment

I'm trying to make my algorithm more readable in 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} 

The result was not so good:

enter image description here

I would like it to appear just the call to the functions without the lot of endif.

I would like something like this:

I would like something like this

Any suggestion? I am trying hard! The classe IEEEtran is : https://ctan.org/pkg/ieeetran?lang=en

1 Answers

Answers 1

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

If so, you just need to replace

\usepackage{algpseudocode} 

with

\usepackage[noend]{algpseudocode} 

Sources:

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment