caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Syntaxe Caml en LaTeX
@ 2005-05-29 11:52 Pierre-Etienne Meunier
  2005-05-29 23:25 ` [Caml-list] " Martin Jambon
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Pierre-Etienne Meunier @ 2005-05-29 11:52 UTC (permalink / raw)
  To: caml-list

Bonjour,

Je voudrais savoir s'il y a un moyen d'intégrer les couleurs de syntaxe 
Caml (comme avec tuareg dans emacs) dans une page LaTeX, pour rendre le 
code présentable.
Amicalement,
Pierre-Etienne Meunier (meunier.pe@free.fr)

Here comes the english version :

I'd like to include Caml code in a LaTeX file, but since it is pretty 
big, I want it to be easily readable. Then I want to keep the colored 
syntax, like in tuareg for emacs. Do you know how to do it ?
Best regards,
Pierre-Etienne Meunier (meunier.pe@free.fr)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Syntaxe Caml en LaTeX
  2005-05-29 11:52 Syntaxe Caml en LaTeX Pierre-Etienne Meunier
@ 2005-05-29 23:25 ` Martin Jambon
  2005-05-30 10:40   ` Jon Harrop
  2005-05-31 19:56   ` ocaml + enscript (was Re: [Caml-list] Syntaxe Caml en LaTeX) Janne Hellsten
  2005-05-29 23:49 ` [Caml-list] Syntaxe Caml en LaTeX Chris Campbell
  2005-05-30  2:01 ` Robert Roessler
  2 siblings, 2 replies; 6+ messages in thread
From: Martin Jambon @ 2005-05-29 23:25 UTC (permalink / raw)
  To: Pierre-Etienne Meunier; +Cc: caml-list

On Sun, 29 May 2005, Pierre-Etienne Meunier wrote:

> Bonjour,
>
> Je voudrais savoir s'il y a un moyen d'intégrer les couleurs de syntaxe
> Caml (comme avec tuareg dans emacs) dans une page LaTeX, pour rendre le
> code présentable.
> Amicalement,
> Pierre-Etienne Meunier (meunier.pe@free.fr)
>
> Here comes the english version :
>
> I'd like to include Caml code in a LaTeX file, but since it is pretty
> big, I want it to be easily readable. Then I want to keep the colored
> syntax, like in tuareg for emacs. Do you know how to do it ?
> Best regards,
> Pierre-Etienne Meunier (meunier.pe@free.fr)

I don't know what people have used so far (you can ask Jon Harrop what he
used for his book http://www.ffconsultancy.com/products/ocaml_for_scientists/).

One solution would be to adapt Caml2html
(http://martin.jambon.free.fr/caml2html.html).
You can either (1) start an independent Caml2latex library/executable and
reuse some code from Caml2html, or (2) make Caml2html polyglot.
IMO solution (1) is better than (2) since the OCaml parser does not
require a lot of maintenance as opposed to the formatting options which
are not really reusable anyway.

Otherwise, you can convert your program to colorized PostScript with
enscript (ask Janne Hellsten, google for "ocaml and enscript") or directly
from emacs.


Martin

--
Martin Jambon, PhD
http://martin.jambon.free.fr



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Syntaxe Caml en LaTeX
  2005-05-29 11:52 Syntaxe Caml en LaTeX Pierre-Etienne Meunier
  2005-05-29 23:25 ` [Caml-list] " Martin Jambon
@ 2005-05-29 23:49 ` Chris Campbell
  2005-05-30  2:01 ` Robert Roessler
  2 siblings, 0 replies; 6+ messages in thread
From: Chris Campbell @ 2005-05-29 23:49 UTC (permalink / raw)
  To: Pierre-Etienne Meunier; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 933 bytes --]

On 29/05/05, Pierre-Etienne Meunier <meunier.pe@free.fr> wrote:
> 
> 
> I'd like to include Caml code in a LaTeX file, but since it is pretty
> big, I want it to be easily readable. Then I want to keep the colored
> syntax, like in tuareg for emacs. Do you know how to do it ?
> Best regards,
> Pierre-Etienne Meunier (meunier.pe@free.fr)


You might consider using the listings package for latex.
http://www.atscire.de/index.php?nav=products/listings

I have not used it for OCaml code, but I think you can use

\lstset{language=[objective]Caml}

or something like that.

It supports small code snippets, larger snippets and separate files.

You can customise it to set the colours of keywords, symbols, etc.

\lstset{keywordstyle=\color{blue}, stringstyle=\color{green}}

It's all documented in the pdf inside the zip.

If it doesn't support of the current ocaml syntax, it's fairly easy to tweak 
it.

[-- Attachment #2: Type: text/html, Size: 1373 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Syntaxe Caml en LaTeX
  2005-05-29 11:52 Syntaxe Caml en LaTeX Pierre-Etienne Meunier
  2005-05-29 23:25 ` [Caml-list] " Martin Jambon
  2005-05-29 23:49 ` [Caml-list] Syntaxe Caml en LaTeX Chris Campbell
@ 2005-05-30  2:01 ` Robert Roessler
  2 siblings, 0 replies; 6+ messages in thread
From: Robert Roessler @ 2005-05-30  2:01 UTC (permalink / raw)
  To: Pierre-Etienne Meunier; +Cc: Caml-list

Pierre-Etienne Meunier wrote:

> Here comes the english version :
> 
> I'd like to include Caml code in a LaTeX file, but since it is pretty 
> big, I want it to be easily readable. Then I want to keep the colored 
> syntax, like in tuareg for emacs. Do you know how to do it ?

You could use the Scintilla (http://www.scintilla.org/) text editing 
component - and the editor based on it, SciTE 
(http://www.scintilla.org/SciTE.html).

It "understands" OCaml source inasmuch as it can syntax color it... 
combined with the ability [in SciTE] to export to LaTeX (as well as 
HTML, PDF and more), your needs may be met.

Note that the specific colors used for the syntax elements are easily 
adjusted by editing the "caml.properties" file.

Robert Roessler
roessler@rftp.com
http://www.rftp.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Syntaxe Caml en LaTeX
  2005-05-29 23:25 ` [Caml-list] " Martin Jambon
@ 2005-05-30 10:40   ` Jon Harrop
  2005-05-31 19:56   ` ocaml + enscript (was Re: [Caml-list] Syntaxe Caml en LaTeX) Janne Hellsten
  1 sibling, 0 replies; 6+ messages in thread
From: Jon Harrop @ 2005-05-30 10:40 UTC (permalink / raw)
  To: caml-list

On Monday 30 May 2005 00:25, Martin Jambon wrote:
> On Sun, 29 May 2005, Pierre-Etienne Meunier wrote:
> > I'd like to include Caml code in a LaTeX file, but since it is pretty
> > big, I want it to be easily readable. Then I want to keep the colored
> > syntax, like in tuareg for emacs. Do you know how to do it ?
>
> I don't know what people have used so far (you can ask Jon Harrop what he
> used for his book
> http://www.ffconsultancy.com/products/ocaml_for_scientists/).

I wrote a little program to color syntax-highlight LyX files by treating 
anything in typewriter font as code. This has several advantages - no need to 
annotate by hand, code can be extracted and even tested, easy to alter the 
document self-consistently and so on.

I chose to put all code snippets on their own minipage, to help lay them out 
aesthetically. However, LaTeX does a poor job of distributing them on the 
page, so any alterations to the document need to be carefully checked to make 
sure the LaTeX output hasn't become very ugly (e.g. huge gaps).

I think the solution I used works reasonably well but there is plenty of room 
for improvement. Ideally, I'd like to get rid of LaTeX...

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists


^ permalink raw reply	[flat|nested] 6+ messages in thread

* ocaml + enscript (was Re: [Caml-list] Syntaxe Caml en LaTeX)
  2005-05-29 23:25 ` [Caml-list] " Martin Jambon
  2005-05-30 10:40   ` Jon Harrop
@ 2005-05-31 19:56   ` Janne Hellsten
  1 sibling, 0 replies; 6+ messages in thread
From: Janne Hellsten @ 2005-05-31 19:56 UTC (permalink / raw)
  To: caml-list

> Otherwise, you can convert your program to colorized PostScript with
> enscript (ask Janne Hellsten, google for "ocaml and enscript") or directly
> from emacs.

For what it's worth, I have made my ocaml enscript states file
available at: http://users.tkk.fi/~jjhellst.

Have fun!

Best regards,
Janne


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-05-31 19:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-29 11:52 Syntaxe Caml en LaTeX Pierre-Etienne Meunier
2005-05-29 23:25 ` [Caml-list] " Martin Jambon
2005-05-30 10:40   ` Jon Harrop
2005-05-31 19:56   ` ocaml + enscript (was Re: [Caml-list] Syntaxe Caml en LaTeX) Janne Hellsten
2005-05-29 23:49 ` [Caml-list] Syntaxe Caml en LaTeX Chris Campbell
2005-05-30  2:01 ` Robert Roessler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).