1

For some reason even when I enable \DontPrintSemicolon there are still semicolons on lines with comments. This is in Algorithm2e version 3.9.

\documentclass[12pt]{article}
\usepackage[lined,boxed]{algorithm2e}% using version 3.9
\usepackage{amsmath}

\newcommand*{\DontPrintSemicolon}[0]{\dontprintsemicolon}%remove for 5.0

%define defaults for algorithm2e
\let \oriAlgorithm=\algorithm
\renewcommand{\algorithm}[2]{
  \oriAlgorithm  % Begin document
    \SetLine
    \DontPrintSemicolon
    \SetKwComment{Comment}{}{}
    \Titleofalgo{ #1 }
    \caption{ #2 }
}

\newcommand*{\Set}[2]{ #1 $\gets$ #2 }
\newcommand*{\SetC}[3]{ #1 $\gets$ #2 \Comment*[r]{#3} }

\begin{document}
  \begin{algorithm}{test}{test to show semicolons existence}
    \SetC{$f$}{$true$}{Some comment}\;
    \Set{$f$}{$\lnot f$}\;
    \Return{$f$}\;
  \end{algorithm}
\end{document}

compiled latex png

nlucaroni
  • 186

1 Answers1

1

5.0 documentation states a bug was fixed regarding this issue,

a bug with side text -- text put into () -- of command macro (SetKwIf and so on) which was always setting a ’;’ even after a \DontPrintSemicolon

nlucaroni
  • 186