#lang racket ;;; Really this module does more than render images, it's a custom renderer ;;; for a lot of stuff specific to morgan's dissertation (require scribble/render scribble/core scribble/private/render-utils racket/runtime-path (prefix-in images: "Images.scrbl") (prefix-in title: "../Racket/Title.scrbl") scribble/pdf-render setup/collects) (define-runtime-path pwd ".") (define-runtime-path output-dir "../Output") (define-runtime-path prefix-file "../Racket/DissertationLatexHeader.tex") (define (scaled-mixin %) (class (xelatex-render-mixin %) (super-new) (inherit install-file) (define/override (render-content e part ri) (cond ;; Scale graphics the way we need to for the image list [(and (image-element? e) ;; (not (disable-images)) (equal? (style-name (element-style e)) "ScaledFig")) (let ([fn (install-file (select-suffix (collects-relative->path (image-element-path e)) (image-element-suffixes e) '(".pdf" ".ps" ".png")))]) (printf "\\includegraphics[width=10cm,height=10cm,keepaspectratio]{~a}" fn))] ;; do the default thing [else (super render-content e part ri)])))) (define (render-images) (render (list images:doc) (list "Images") #:render-mixin scaled-mixin #:prefix-file prefix-file #:dest-dir output-dir)) (define (render-all) (render (list title:doc) (list "Dissertation") #:render-mixin scaled-mixin #:prefix-file prefix-file #:dest-dir output-dir)) (define (run) (match (current-command-line-arguments) [(vector "images") (render-images) (displayln "Wrote Output/Images.pdf")] [(vector "all") (render-all) (displayln "Wrote Output/Dissertation.pdf")] [_ (error "Only accepts either \"images\" or \"all\"")])) (module+ main (run))