2

Is there such a package where the ending of a for loop or an if statement is not displayed? I don't mind for the LaTeX code itself, but for the result.

For example, I am using this:

\documentclass{article}

\usepackage{algorithm}
\usepackage{algorithmic}
\newcommand{\algorithmicinput}{\textbf{input}}
\newcommand{\INPUT}{\item[\algorithmicinput]}

\begin{document}

\begin{algorithm}[H]
    \caption{Dolphinn: Preprocessing (data structure)}
    \label{DolphinnPrep}
    \begin{algorithmic}
    \INPUT{Parameter $d'$.}
    \STATE Initialize empty hashtable $T$.
    \FOR{$i = 1$ to $d'$}
        \STATE Sample $h_i \in F$ u.a.r.
        \FOR{each $x \in h_i(P)$}
            \STATE{Flip a fair coin and assign the result to $f_i(x)$.}
        \ENDFOR
    \ENDFOR
    \STATE{For all $p \in P$, $f(p)=(f_1(h_1(p)), \ldots, f_{d'}(h_{d'}(p)))$.}
    \STATE{For all $p \in P$, add $p$ to the bucket of $T$ with key f(p)$.}
\end{algorithmic}
\end{algorithm}

\end{document}

which produces this:

enter image description here

Notice the "end for" lines. I want to get rid of them. How?

Same behavior is desired for the if statements.

1

Instead of using algorithmic, use algcompatible with the noend package option:

enter image description here

\documentclass{article}

\newcommand{\MM}{\mathcal{M}}

\usepackage{algorithm}
\usepackage[noend]{algcompatible}
\newcommand{\algorithmicinput}{\textbf{input}}
\newcommand{\INPUT}{\item[\algorithmicinput]}

\begin{document}

\begin{algorithm}[H]
  \caption{Dolphinn: Preprocessing (data structure)}
  \label{DolphinnPrep}
  \begin{algorithmic}
    \INPUT{Metric $(\MM, d_{\MM})$, approximation factor $c>1$, LSH family $F=F(c,r)$, data set $P \subset \MM$, parameter $d'$.}
    \STATE Initialize empty hashtable $T$.
    \FOR{$i = 1$ to $d'$}
      \STATE Sample $h_i \in F$ u.a.r.
      \FOR{each $x \in h_i(P)$}
        \STATE{Flip a fair coin and assign the result to $f_i(x)$.}
      \ENDFOR
    \ENDFOR
    \STATE{For all $p \in P$, $f(p)=(f_1(h_1(p)), \ldots, f_{d'}(h_{d'}(p)))$.}
    \STATE{For all $p \in P$, add $p$ to the bucket of $T$ with key $f(p)$.}
  \end{algorithmic}
\end{algorithm}

\end{document}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.