* ANNOUNCE: OCamlTeX 0.5 available for beta-testing
@ 2006-05-09 15:38 Geoffrey Alan Washburn
0 siblings, 0 replies; only message in thread
From: Geoffrey Alan Washburn @ 2006-05-09 15:38 UTC (permalink / raw)
To: caml-list
OCamlTeX is a wrapper for LaTeX and its variants (pdfLaTeX, XeTeX, etc.)
that provides the ability to define macros in terms of OCaml code.
OCamlTeX is derived from Scott Pakin's PerlTeX, but with some
enhancements that are useful for OCaml.
Using OCamlTeX is straightfoward. Just add
\usepackage{ocamltex}
to your document's preamble and you can then start writing OCaml macros like
\ocamlnewcommand{\mymacro}[x,y]{ "\\textbf{" ^ y ^ x ^ "}" }
where unlike LaTeX and PerlTeX instead of writing the number of
arguments the function takes within the square brackets, you can
explicitly name them. What is actually going on is that OCamlTeX and
TeX/LaTeX are communicating via temporary files, and the above bit of
LaTeX corresponds to defining the OCaml function
let rec latex_mymacro (x : string) (y : string) : string =
"\\textbf{" ^ y ^ x ^ "}";;
It is then possible to use your macro just like you would any other
LaTeX macro. The macro invocation
\mymacro{foo}{bar}
expands to
\textbf{barfoo}
and is then expanded further. Consequently, macros defined using
\ocamlnewcommand can either call themselves recursively by using
"latex_mymacro" or outputing a call to "\mymacro" in their output.
OCamlTeX differs from PerlTeX in two notable ways (other being
written in OCaml and providing OCaml macros):
* First, OCamlTeX currently doesn't support LaTeX style optional
arguments. I can imagine in the putting this back in by
making use of OCaml's optional argument functionality.
* Second, OCamlTeX provides an additional macro \ocamlexec, that
allows for executing arbitrary top-level code. For example,
this is useful if you want to open a module, or import OCaml
code in bulk.
I expect this will be especially useful for those of you that write
papers about software/languages you've written in OCaml because it makes
it easy to actually call your code from within your document and
maintain consistency. So, for example you can always be sure your code
examples type-check. I think it would be interesting to consider a
Haskell port, because monads would be very helpful for structuring a
more extensive TeX API, rather than always just manipulating strings.
However, I am not as familiar with how to implement this sort of
software in Haskell.
The current version of OCamlTeX is available from the world readable
Subversion repository: https://svn.cis.upenn.edu/svnroot/ocamltex/. If
you're interested in hacking on it, I can give you commit access. You
will need the OCaml library/package "cash" to use it. Bug reports and
feature suggestions welcome.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-05-09 15:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-09 15:38 ANNOUNCE: OCamlTeX 0.5 available for beta-testing Geoffrey Alan Washburn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox