diff options
Diffstat (limited to 'Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-algorithms.html')
-rw-r--r-- | Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-algorithms.html | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-algorithms.html b/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-algorithms.html new file mode 100644 index 00000000000..61cf79d5c30 --- /dev/null +++ b/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-algorithms.html @@ -0,0 +1,107 @@ +<head> +<title>UK TeX FAQ -- question label algorithms</title> +</head><body> +<h3>Typesetting pseudocode in LaTeX</h3> +<p/>There is no consensus on the ‘right’ way to typeset pseudocode. +Consequently, there are a variety of LaTeX packages to choose from +for producing æsthetically pleasing pseudocode listings. +<p/>Pseudocode differs from actual program listings in that it lacks +strict syntax and semantics. Also, because pseudocode is supposed to +be a clear expression of an algorithm it may need to incorporate +mathematical notation, figures, tables, and other LaTeX features +that do not appear in conventional programming languages. + <a href="FAQ-codelist.html">Typesetting program listings</a> is described + elsewhere. + +<p/>You can certainly create your own environment for typesetting +pseudocode using, for example, the <code>tabbing</code> or +<code>list</code> environments — it’s not difficult, but it may +prove boring. So it’s worth trying the following packages, all +designed specifically for typesetting pseudocode. +<p/>The <i>algorithms</i> bundle (which contains packages +<i>algorithm</i> and <i>algorithmic</i>, both of which are +needed for ordinary use) has a simple interface and produces fairly +nice output. It provides primitives for statements, which can contain +arbitrary LaTeX commands, comments, and a set of iterative and +conditional constructs. These primitives can easily be redefined to +produce different text in the output. However, there is no support +for adding new primitives. Typesetting the pseudocode itself is +performed in <i>algorithmic</i>; the <i>algorithms</i> package +uses the facilities of the <i>float</i> package to number +algorithms sequentially, enable algorithms to float like figures or +tables, and support including a List of Algorithms in a document’s +front matter. +<p/>Packages in the <i>algorithmicx</i> bundle are similar both in +concept and output form to <i>algorithmic</i> but additionally +provide support for adding new keywords and altering the formatting. +It provides the <i>algpseudocode</i> package which is (almost) a +drop-in replacement for <i>algorithmic</i>. Another package in the +bundle, <i>algpascal</i>, uses Pascal-like keywords, indents +differently from <i>algpseudocode</i>, and puts command arguments +in maths mode instead of text mode. There is no floating environment +but <i>algorithmicx</i>, like <i>algorithmic</i>, is compatible +with the <i>algorithm</i> package. +<p/>The <i>alg</i> package, like <i>algorithms</i>, offers a +floating algorithm environment with all of the ensuing niceties. +<i>alg</i>, however, can caption its floats in a variety of +(natural) languages. In addition, <i>alg</i> unlike +<i>algorithms</i>, makes it easy to add new constructs. +<p/>The <i>newalg</i> package has a somewhat similar interface to +<i>algorithms</i>, but its output is designed to mimic the rather +pleasant typesetting used in the book “<em>Introduction to Algorithms</em>” +by Corman, Leiserson, Rivest and Stein. Unfortunately, +<i>newalg</i> does not support a floating environment or any +customisation of the output. +<p/>“<em>Bona fide</em>” use of the style of “Introduction to +Algorithms” may be achieved with Cormen’s own <i>clrscode</i>: +this is the package as used in the second edition of the book. +<p/>Similarly, the style of +“<em>Combinatorial Algorithms: Generation, Enumeration and Search</em>” +is supported by the <i>pseudocode</i> package, written by the +authors of the book. It has the common ‘Pascal-like’ style, and has +some interesting constructs for what one thinks of as Pascal blocks. +<p/>The <i>algorithm2e</i> is of very long standing, and is widely used +and recommended. It loads the <i>float</i> package to provide the +option of floating algorithm descriptions, but you can always use the +“<code>H</code>” option of <i>float</i> to have the algorithm appear +“where you write it”. +<p/>The usage of the <i>program</i> package is a little different from +that of the other packages. It typesets programs in maths mode +instead of text mode; and linebreaks are significant. +<i>program</i> lacks a floating environment but does number +algorithms like <i>alg</i> and <i>algorithms</i>. Customisation +and extension are not supported. Documentation of the +<i>program</i> package (such as it is) appears in a file +<i>program.msg</i> in the distribution. +<p/>None of the above are perfect. The factors that should influence your +choice of package include the output style you prefer, how much you +need to extend or modify the set of keywords, and whether you require +algorithms to float like figures and tables. + + + + + + + + + + + + + + + +<dl> +<dt><tt><i>algorithm2e.sty</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/algorithm2e.zip">macros/latex/contrib/algorithm2e</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/algorithm2e.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/algorithm2e/">browse</a>) +<dt><tt><i>algorithmicx bundle</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/algorithmicx.zip">macros/latex/contrib/algorithmicx</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/algorithmicx.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/algorithmicx/">browse</a>) +<dt><tt><i>algorithms bundle</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/algorithms.zip">macros/latex/contrib/algorithms</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/algorithms.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/algorithms/">browse</a>) +<dt><tt><i>alg.sty</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/alg.zip">macros/latex/contrib/alg</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/alg.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/alg/">browse</a>) +<dt><tt><i>clrscode.sty</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/clrscode.zip">macros/latex/contrib/clrscode</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/clrscode.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/clrscode/">browse</a>) +<dt><tt><i>float.sty</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/float.zip">macros/latex/contrib/float</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/float.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/float/">browse</a>) +<dt><tt><i>newalg.sty</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/newalg.zip">macros/latex/contrib/newalg</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/newalg.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/newalg/">browse</a>) +<dt><tt><i>program.sty</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/program.zip">macros/latex/contrib/program</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/program.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/program/">browse</a>) +<dt><tt><i>pseudocode.sty</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/pseudocode.zip">macros/latex/contrib/pseudocode</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/pseudocode.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/pseudocode/">browse</a>) +</dl> +<p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=algorithms">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=algorithms</a> +</body> |