From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id B0560BB84 for ; Tue, 9 May 2006 17:39:44 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k49FdhMA014047 for ; Tue, 9 May 2006 17:39:44 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA31948 for ; Tue, 9 May 2006 17:39:43 +0200 (MET DST) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k49FdgP4026461 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Tue, 9 May 2006 17:39:43 +0200 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1FdUIt-0002WO-NH for caml-list@inria.fr; Tue, 09 May 2006 17:39:15 +0200 Received: from lvn514-2.cis.upenn.edu ([158.130.50.247]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 09 May 2006 17:39:15 +0200 Received: from geoffw by lvn514-2.cis.upenn.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 09 May 2006 17:39:15 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Geoffrey Alan Washburn Subject: ANNOUNCE: OCamlTeX 0.5 available for beta-testing Date: Tue, 09 May 2006 11:38:25 -0400 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: lvn514-2.cis.upenn.edu User-Agent: Thunderbird 1.5.0.2 (X11/20060420) Sender: news X-Miltered: at concorde with ID 4460B7BF.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4460B7BE.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; upenn:01 variants:01 pdflatex:01 ocaml:01 ocaml:01 usepackage:01 textbf:01 corresponds:01 rec:01 textbf:01 invocation:01 foo:01 ocaml's:01 haskell:01 monads:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 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.