1

I'm new to Latex and currently writing pseudocode using algorithmic. I want to remove all "end if" lines from the code. I tried to use \usepackage[noend]{algpseudocode} but it does not work (see the image). Please help. Thank you!

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\algnewcommand\algorithmicinput{\textbf{Input:}}
\algnewcommand\algorithmicoutput{\textbf{Output:}}
\algnewcommand\Input{\item[\algorithmicinput]}%
\algnewcommand\Output{\item[\algorithmicoutput]}%
\algnewcommand{\Donnees}{\Statex \textbf{$x$}}

\begin{document}





\begin{algorithm}
\caption{The recommendation }
\begin{algorithmic}[1]
\Donnees: a scenario

\Input{$Stakeholder_x, Solutions_x, Architectures_x$}
\Output{$Issues_x, Measures_x, Attributes_x$}
\FORALL{$Solution$ in $Solutions_x$}
    \IF{$Solution$ in $Solutions_{Stakeholder_x}$}
        \IF{$Solution_{Components}$ not in $Components_x$}
            \STATE add $Solution_{Components}$ to $Components_x$
        \ENDIF
        \IF{$Issues_{Solution}$ not in $Issues_x$}
            \STATE add $Issues_{Solution}$ to $Issues_x$
        \ENDIF
        \FORALL{$Architecture$ in $Architectures_x$}
            \IF{$Architecture$ in $Solution_{Architectures}$}
                \IF{$Component_{Architecture}$ not in $Components_x$}
                    \STATE add $Component_{Architecture}$ to $Components_x$
                \IF{$Issues_{Architecture}$ not in $Issues_x$}
                    \STATE add $Issues_{Architecture}$ to $Issues_x$
                \ENDIF
                \ENDIF
            \ENDIF
        \ENDFOR
    \ENDIF
\ENDFOR

\end{algorithmic}
\end{algorithm}

enter image description here

  • You should consider keeping them. Not all readers understand python like pseudocode, so the end parts do serve a purpose. – daleif Feb 28 at 17:23
  • You are right but I will put vertical lines to highlight the blocks. The main reason I want to remove the block ends is to save space because the algorithm is too long (I only put here a small part of it). – fsfr23 Feb 28 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.