[racket] Integrating scribble and LaTeX

From: Eric Tanter (etanter at dcc.uchile.cl)
Date: Thu Jun 23 11:25:40 EDT 2011

Thanks a lot Matthew, this is a really handy feature!

To add to the arguments of Don and others on why this might be necessary, I faced another situation recently, quite common in research: collaborative paper writing. You can't reasonably hope that all your co-authors will want to use scribble (unless they're all PLTers of course ;)), while they are all already expert latex users (and sometimes addicts). 

So while it's true it is "possible" to go the other way, the possibility to just include bits of scribble generated code here and there is just great. 

And that may finally be an easy-to-install/use replacement to Slatex...

So, I did a quick experiment of the new feature. Report below:

- I took an existing paper (written with sigplanconf). 

- I wrote a small scribble (test.scrbl):
#lang scribble/manual
@(require scribble/eval)
(define add 
  (λ (n)
    (λ (m)
      (+ m n))))
(define add2 (add 2))
(add2 5)

- compiled with scribble as indicated by Matthew

- included the generated files in the header

- inserted a figure with the scribble somewhere in the middle of the paper

And... it (mostly) works!

The output is good, great looking. But, there are a few errors in the compilation. 

First: ! LaTeX Error: Option clash for package color.

I realized that the paper already included the color package, and so there is a conflict with the way scribble also includes it. 
So I removed the \usepackage{color} from the paper source.

Now it didn't work, because of undefined commands related to the color package as well.
I figured out that it is because the generated files were not included in the correct order!

scribble.tex has to go first:


And now, everything works perfectly.

Bottom line:
- do not \usepackage{color} explicitly in the paper (there may be similar conflicts for other packages)
- the order in which the generated files are included matters. scribble.tex has to go first (there may be other dependencies that I haven't came across)

Hope this helps,

-- Éric

On Jun 22, 2011, at 10:01 AM, Matthew Flatt wrote:

> At Tue, 21 Jun 2011 15:39:06 -0500, Don Blaheta wrote:
>> If I put a single
>> example in a file and then run 
>>   scribble --latex myfile.scrbl
>> I get a LaTeX file that is an entire \document, not one that I can
>> \include elsewhere.
> I've added a `--latex-section' mode to `scribble', so
> scribble --latex-section 0 myfile.scrbl
> will generate "myfile.tex" as something that you can \include. It also
> generates several other ".tex" files, which provide Latex commands that
> are potentially needed by "myfile.tex", so those extras need to be
> included in the document preamble.
> The set of extra ".tex" files depends on what you use in
> "myfile.scrbl". It should work well enough to render "myfile.scrbl",
> see what ".tex" files you get, and include those. If you have multiple
> Scribble-generated pieces, they'll generate (mostly) the same extra
> ".tex" files, and obviously you'll need to include only one copy of
> each in the preamble.
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users

Posted on the users mailing list.