[plt-scheme] Re: Scribble: raw text

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Mar 14 08:20:05 EDT 2010

At Fri, 12 Mar 2010 17:16:15 +0100, Laurent wrote:
> >
> >
> > How to write raw (untransformed) text on the output of scribble (#lang
> > scribble/base) ?
> > I *really* miss the LaTeX equations, so I'd like the $, \, ^, etc. to not
> > be translated at the generation of the tex file.
> > I suppose this bypass is exactly what should be avoided, but I'm greedy and
> > I want the best of Scribble and LaTeX.
> >
> > The `literal' and `verbatim' functions don't solve the problem.
> >
> 
> Found!
> 
> In scribble/latex-render.ss, line 257, I added the following line (DrScheme
> 4.2.4):
> [(raw) (core-render e 'exact)]
> 
> Now in my scribble file (with #lang scribble/base), I defined:
> @(define (math . text)
>    (make-element
>     'raw
>     @list{$@|text|$}))
> 
> And now I can use:
> @math{\lambda^2=\sum_i{5+i}}
> 
> (warning: math is already defined in scribble/manual, so in case of
> requiring the latter, except-in must be used)
> Now thanks to Scribble writing LaTeX reports will be a piece of cake.
> Hopefully.
> 
> If anyone knows a way that does not involve modifying "core" files, please
> let me know.

If you create a style with with 'exact-chars property, then the content
of an element using the style will be rendered to Latex without escapes.
(I've added the missing documentation for this property.)

Here's an example:

 #lang scribble/base
 @(require scribble/core)

 @(define (math . strs)
    (make-element (make-style "hbox" '(exact-chars)) 
                  (append '("$") strs '("$"))))

 @math{\lambda^2=\sum_i{5+i}}

The "hbox" in that example could be any suitable Latex command. For
'exact-chars to work, the style's name has to be some command.



Posted on the users mailing list.