[racket] Setting LaTeX Prefix, style and extra files from within file in DrR

From: Stephen De Gabrielle (spdegabrielle at gmail.com)
Date: Fri Oct 10 12:03:18 EDT 2014

Thanks,

I think I'm going about this the wrong way.

What I wanted to do was switch from LaTeX (before I had to learn to much),
to racket (still learning), but bring a nice package I had from latex[1].
I did try dropping the location of my tma.sty code into your example[2],
but assuming 'its all just LaTex/Tex' seems to be wrong as the error[0] I
get tells me that my LaTeX definitions are missing when pdfLaTeX tries to
make the PDF.

I think this is possible if I make a library like scribble/book and
scribble/jfp as they do put in the document preamble stuff
>
"\\documentclass[a4paper,12pt{article}\n\\usepackage{cancel}\n\\usepackage{tma}\n"

I've started on this, stealing functions cargo-cult-style from
scribble/book/lang.rkt, scribble/private/defaults.rkt (ignore #lang
scheme/base!) and
https://github.com/soegaard/bracket/blob/master/docs/pr-math.rkt , but I
still get the error[0] that LaTeX definitions have not yet been read.
(embarrassing examples attached)

Am I going at this in the right direction? Scribble seems to include a lot
of its own .TeX files and I'm concerned I'm doing this the wrong way.

Thanks for your help,

Stephen

PS I must do the assignment! (Its not Scribble or Racket)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

[0] error
! Undefined control sequence.
l.408 \myname
             {Stephen De Gabrielle}
The control sequence at the end of the top line
of your error message was never \def'ed.


;;;;;;;;;;;;;
[1] 'Tutor Marked Assignment' tma.sty
https://github.com/spdegabrielle/OU-LaTeX-TMA-package
example of use
-----------------------
\documentclass[a4paper,12pt]{article}
\usepackage{tma}   % finds tma.sty in  (standard?) location
~/texmf/latex/tma/tma.sty

\myname{Stephen De Gabrielle}
\mypin{A3470402}
\mycourse{MST124}
\mytma{Unit 1 notes}
---------
;;;;;;;;;;;;;

[2] Thought I'd try force it without understanding what I was doing...this
failed:
-----------------------
#lang scribble/manual

@(require scribble/core scribble/latex-properties scribble/html-properties)

@(define book-style
   (make-style "htdp2e-book"
               (list
                'toc
                (make-tex-addition "/Volumes/Macintosh
HD/Users/spdegabrielle/Library/texmf/tex/latex/tma/tma.sty"))))

@(make-element "myname" "Stephen De Gabrielle")
@(make-element "mypin" "A3470402")
@(make-element "mycourse" "MST124")
@(make-element "mytma" "Unit 1 notes")

Every idiot can learn to program in 24 hours.

This idiot is still trying... :)
--------------------------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

[4]
----------------
;;; From scribble/book

(define-syntax-rule (module-begin id . body)
  (#%module-begin id (post-process) () . body))

(define ((post-process) doc)
  (add-defaults doc
                (string->bytes/utf-8 (string-append
"\\documentclass[a4paper,12pt]{article}\n\\usepackage{cancel}\n\\usepackage{tma}\n"

unicode-encoding-packages))
                (scribble-file "book/style.tex")
                null
                #f))






;;;;;;;;;;;;;

On Fri, Oct 10, 2014 at 3:02 PM, Matthias Felleisen <matthias at ccs.neu.edu>
wrote:

>
> This is roughly what HtDP/2e looks like as source:
>
>
> -------------------------------------------------------------------------------------------
> #lang scribble/manual
>
> @(require scribble/core scribble/latex-properties scribble/html-properties)
>
> @(define book-style
>    (make-style "htdp2e-book"
>                (list
>                 'toc
>                 (make-css-addition "Shared/shared.css")
>                 (make-tex-addition "Shared/shared.tex"))))
>
> @;
> ------------------------------------------------------------------------------
> @title[#:tag "htdp2e" #:style book-style ]{How to Design Programs, Second
> Edition}
>
> Every idiot can learn to program in 24 hours.
>
> -------------------------------------------------------------------------------------------
>
> It comes with two files, which I have in a subdirectory called Shared:
> shared.css and shared.tex.
> It is there that I store the latex and css properties.
>
> Put this in DrRacket, save it in a Tmp directory, and run the PDF and HTML
> generation.
>
> You can put a lot of things into these CSS and TEX files. -- Matthias
>
>
>
>
>
>
> On Oct 9, 2014, at 7:23 PM, Stephen De Gabrielle <spdegabrielle at gmail.com>
> wrote:
>
> > Hi,
> >
> > Is is possible to use "(part (style #f (list (make-latex-defaults ..."
> to set the LaTeX prefix (and style and extra files) from within a scribble
> file.
> >
> > My example below gets a contract violation because I've not specified a
> style or any extra files.
> >
> > I can see the examples of it being done as a language for JFP and Book,
> but I can't work out how to just do it in the preamble if my scribble file.
> (I don't really want to create a new #lang)
> >
> > kind regards,
> > Stephen
> >
> > ----
> >
> > #lang scribble/base
> > @(require scribble/core
> >    scribble/latex-properties
> >           scribble/latex-prefix)
> >
> >
> > @(define setup-tma
> >    (part
> >     (style #f (list (make-latex-defaults
> >   (string->bytes/utf-8 (string-append
> "\\documentclass[a4paper,12pt]{article}\n\\usepackage{cancel}\n\\usepackage{tma}\n"
> >                                       unicode-encoding-packages))
> >   ""
> >   null)
> >                     ))
> >     '()))
> >
> > @(require "pr-slides.rkt" scribble/latex-properties)
> > @setup-math
> > @setup-tma
> > @title{Math Assignment 1}
> > @author{Prabhakar Ragde}
> > @section{First Test}
> > This @emph{should} be a formula: @math-in{x^2 + y^2}.
> > @section{Second Test}
> >
> > struct
> > (struct               latex-defaults (prefix style extra-files)
> >     #:extra-constructor-name make-latex-defaults)
> >       prefix          :
> > (or/c bytes? path-string?
> >       (cons/c 'collects (listof bytes?)))
> >       style           :
> > (or/c bytes? path-string?
> >       (cons/c 'collects (listof bytes?)))
> >       extra-files             :
> > (listof (or/c path-string?
> >               (cons/c 'collects (listof bytes?))))
> > Used as a style property on the main part of a document to set a default
> prefix file, style file, and extra files (see Configuring Output). The
> defaults are used by the scribblecommand-line tool for and --latex or --pdf
> mode if none are supplied via --prefix and --style (where extra-files are
> used only when prefix is used). A byte-string value is used directly like
> file content, and a path can be a result of path->main-collects-relative.
> > ____________________
> >  Racket Users list:
> >  http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20141010/0a62cba4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scribble-tma.rkt
Type: application/octet-stream
Size: 3588 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20141010/0a62cba4/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scribble-tma-test.rkt
Type: application/octet-stream
Size: 1793 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20141010/0a62cba4/attachment-0001.obj>

Posted on the users mailing list.