[racket] Integrating scribble and LaTeX

 From: Prabhakar Ragde (plragde at uwaterloo.ca) Date: Wed Jun 22 08:17:44 EDT 2011 Previous message: [racket] Integrating scribble and LaTeX Next message: [racket] Integrating scribble and LaTeX Messages sorted by: [date] [thread] [subject] [author]

Don Blaheta wrote:

> I certainly don't expect that a feature be implemented just because I
> want it, and even good features may take a while due to being low
> priority or whatever.  And there may well be some technical impediment
> to just creating a scribble.sty and working from there that I (a
> newcomer to the scene) can't see yet.  But even if you're attempting
> evangelism (and perhaps especially then), the correct answer to "How do
> I X" should in general not be "You shouldn't even want to X, you should
> Y instead".  This response feels a lot like the rightly-derided
> responses of "install linux!" whenever anyone asked "how to I get
> Windows to..." on certain message boards a few years back: unhelpful and
> annoying.

I'm sorry if my response was unhelpful and annoying. I've only glanced
at Scribble internals and I've only been scribbling for a few weeks, but
it has gone fairly quickly for me. So let me try to be more helpful.

What would be the impediment to just \including a Scribble-generated
LaTeX file in another? The generated file would use a bunch of macros
that need to be defined, and would load a bunch of packages in the
preamble. You need those macro definitions and those package declarations.

So, in an empty directory, create a file called empty.scrbl, with the
single line:

#lang scribble/manual

Run:

scribble --latex empty.scrbl

Now look at empty.tex, which has been generated. Looking at
machine-generated LaTeX, or even a human-written class file, can be a
horrible experience, but this isn't at all bad. It's pretty easy to see
what is in the preamble here and what should go in your preamble. The
document body is almost empty: two hooks (\preDoc and \postDoc) that you
can ignore, and a \label that you can probably ignore. So take
everything from the first \usepackage to just before the
\begin{document}, and save it in the file from-scribble.tex. Make sure
your LaTeX document has \include from-scribble.tex in its preamble.

Then, for each example.scrbl written in Scribble, render it to LaTeX,
open it up in an editor, strip off everything from the start to the
\preDoc and \label commands, and from \postDoc to the end (last two
lines), save it, and \include example.tex at the right spot in your
document. (Warning: I haven't done this myself, since I haven't even had
breakfast yet. Other stuff might break. But I doubt it, given my
experience with writing my own prefix files for Scribble-generated LaTeX.)

You can see that the last bit is easily scripted, if you have lots of
examples. And you can see that the feature you want shouldn't be too
hard to include as an option to scribble' on the command line, with
some thought as to how that might be best achieved. But until then, you
have a workaround that's not too bad, I think. --PR

`

 Posted on the users mailing list. Previous message: [racket] Integrating scribble and LaTeX Next message: [racket] Integrating scribble and LaTeX Messages sorted by: [date] [thread] [subject] [author]