From: Geoffrey Alan Washburn <geoffw@cis.upenn.edu>
To: caml-list@inria.fr
Subject: ANNOUNCE: OCamlTeX 0.5 available for beta-testing
Date: Tue, 09 May 2006 11:38:25 -0400 [thread overview]
Message-ID: <e3qd23$e6k$1@sea.gmane.org> (raw)
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.
reply other threads:[~2006-05-09 15:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='e3qd23$e6k$1@sea.gmane.org' \
--to=geoffw@cis.upenn.edu \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox