1

I've seen this nice algorithm sytle in Stachurski (2009), "Economic Dynamics", p.74.

  • Does someone know what package, environment or settings he used?

algo

3
  • 1
    Use package algorith2e
    – yannisl
    Jun 26, 2015 at 12:55
  • Do you mean algorithm2e? Jun 26, 2015 at 13:28
  • @PaulStiverson Yes sure, that was a typo. Just watch out for hyperref problems with it.
    – yannisl
    Jun 26, 2015 at 17:06

2 Answers 2

4

Algorithm2e is the package to use:

\documentclass{amsart}

\usepackage[ruled]{algorithm2e}
\usepackage{mathpazo}
\SetAlgoInsideSkip{medskip}

\begin{document}

\begin{algorithm}
    %\BlankLine
    \DontPrintSemicolon
    \For{i in 1 to n}{
    draw $X\sim\psi$\;
        \For{j in 1 to t}{
        draw $X\sim p(X,dy)$
        }
        set $X^i_t=X$\;
    }
    \Return{$(1/n)\sum^n_{i=1}\mathbb{1}\{X^i_t=y\}$}
    %\BlankLine
\caption{Approximate marginal distribution}
\end{algorithm}
\end{document}

enter image description here

Later: I noticed that the original sample had some additional space at the beginning and end of the algorithm. At first, as you can see, I tried \BlankLine, but that seemed like a kluge, so I used \SetAlgoInsideSkip{medskip} so as to be the default.

0
3

You can use the algorithm2e package. The documentation is available from CTAN. Here is a quick workup of the algorithm, but note that there are many options you can tweak to get the appearance just as you want it.

\documentclass{article}
\usepackage{algorithm2e, bbold}

\begin{document}
    \begin{algorithm}
        \For{i in 1 to n} {
            draw $X \sim \psi$\;
            \For{j in 1 to t}{
                draw $X \sim p(X,dy)$\;
            }
            set $X_t^i = X$\;
        }
        \Return  $(1/n) \sum_{i=1}^n \mathbb{1} \left\{X_t^i = y\right\} $
    \end{algorithm}
\end{document}

The above LaTeX gives the following output:

algorithm reproduced

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .