You can do the formatting using a table for alignment of the labels, manual spacing for indentation and manual typesetting of each word (paying attention to spacing).

$$\begin{array}{ll} & \mathit{stringlen} \leftarrow \text{length of } \mathit{string}. \\ & \mathit{i} \leftarrow \mathit{patlen}. \\ \mathit{top}: & \text{if } \mathit{i} \gt \mathit{stringlen} \text{ then return false}. \\ … \\ & \text{if } \mathit{string}(\mathit{i}) = \mathit{pat}(\mathit{i}) \\ & \quad \text{then} \\ … \\ \end{array}$$

But this is painful for many reasons. The source is hard to read and edit. The rendering of such large blocks of MathJax is slow in some browsers. I hate to think what this would sound like on a screen reader. And I don't think your sample output is particularly pretty anyway.

I would use the native text markup. It's perfectly suitable for a nested structure.

* Let $\mathit{stringlen} = \mathrm{length}(\mathit{string})$
* Set $i = \mathit{patlen}$
* While $i \lt \mathit{stringlen}$:
* Set $j = \mathit{patlen}$
* While $j \lt 0$:
* …
* Return false.

This is easier to do with structured code than with goto. But you shouldn't be using goto when loops would do anyway.

[Source code of this post](https://cs.meta.stackexchange.com/revisions/2d5663e0-e341-4364-8c61-1d66668a224a/view-source) ([other revisions](https://cs.meta.stackexchange.com/posts/1471/revisions))