1
$\begingroup$

What is the recommended way to typeset algorithms?

For example, I have a question about an algorithm related to automata theory, and I would like to render the algorithm in my question.

In Latex I would use the algorithmic package and then get on with STATE and WHILE, etc. This does not seem to work here however, so is it recommended that I format the algorithm in html, with a numbered, ordered list and the individual details in jsmath/latex or is there some other tacitly agreed upon protocol?

$\endgroup$
2
  • 2
    $\begingroup$ This type of question is more appropriate over at the meta site. $\endgroup$ Jun 25, 2010 at 8:48
  • $\begingroup$ Closed: this is for meta. $\endgroup$ Jun 25, 2010 at 15:50

1 Answer 1

2
$\begingroup$

To display code, indent it four spaces -- this is the markdown syntax for code blocks. For example:

factorial :: Integer -> Integer
factorial 0 = 1 
factorial n = n * factorial (n - 1)

If you need to put some code inline, then put it in backticks -- "Integer is a type". Unfortunately the code block code seems to suppress jsMath, however.

$\endgroup$
2
  • $\begingroup$ thanks for the tip, but definitely need a solution that supports both the algorithm notation and mathjs style markup. I guess html is the way to go? $\endgroup$ Jun 25, 2010 at 12:43
  • $\begingroup$ sadly, no. The formatter allows very little by way of actual HTML. I recommend that you search on meta as there are several discussions with links there that may help you. $\endgroup$ Jun 25, 2010 at 13:50

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