diff --git a/collects/scribble/latex-render.rkt b/collects/scribble/latex-render.rkt index e3c7d7f4..0dc8703f 100644 --- a/collects/scribble/latex-render.rkt +++ b/collects/scribble/latex-render.rkt @@ -1,12 +1,12 @@ -#lang scheme/base +#lang at-exp racket/base (require "core.rkt" "latex-properties.rkt" "private/render-utils.rkt" - scheme/class - scheme/runtime-path - scheme/port - scheme/string - scheme/list + racket/class + racket/runtime-path + racket/port + racket/string + racket/list setup/main-collects file/convertible) (provide render-mixin @@ -799,6 +799,7 @@ ;; Which parts are necessary may depend on the latex version, ;; though, so we keep this table around to avoid regressions. (case c + [(#\╔ #\═ #\╗ #\║ #\╚ #\╝) (box-character c)] [(#\u2011) "\\mbox{-}"] ; non-breaking hyphen [(#\uB0) "$^{\\circ}$"] ; degree [(#\uB2) "$^2$"] @@ -1012,6 +1013,55 @@ [else c])])]) c)]))) (loop (add1 i))))))) + + + (define/private (box-character c) + (define (combine . args) + (apply string-append + (filter (λ (x) (not (regexp-match #rx"^[ \n]*$" x))) args))) + (define (adjust % v) + (define num (* % (/ v 10) 10)) + (define i-part (floor num)) + (define d-part (floor (* 10 (- num i-part)))) + (format "~a.~a" i-part d-part)) + (define (x v) (adjust 4/10 v)) + (define (y v) (adjust 6/10 v)) + (case c + [(#\╔) + @combine{\begin{picture}(@x[10],@y[10])(0,0) + \put(@x[2],@y[6]){\line(1,0){@x[8]}} + \put(@x[3],@y[5]){\line(1,0){@x[7]}} + \put(@x[2],@y[0]){\line(0,1){@y[6]}} + \put(@x[3],@y[0]){\line(0,1){@y[5]}} + \end{picture}}] + [(#\═) @combine{\begin{picture}(@x[10],@y[10])(0,0) + \put(@x[0],@y[6]){\line(1,0){@x[10]}} + \put(@x[0],@y[5]){\line(1,0){@x[10]}} + \end{picture}}] + [(#\╗) @combine{\begin{picture}(@x[10],@y[10])(0,0) + \put(@x[0],@y[6]){\line(1,0){@x[8]}} + \put(@x[0],@y[5]){\line(1,0){@x[7]}} + \put(@x[8],@y[0]){\line(0,1){@y[6]}} + \put(@x[7],@y[0]){\line(0,1){@y[5]}} + \end{picture}}] + [(#\║) @combine{\begin{picture}(@x[10],@y[10])(0,0) + \put(@x[3],@y[10]){\line(0,-1){@y[10]}} + \put(@x[2],@y[10]){\line(0,-1){@y[10]}} + \end{picture}}] + [(#\╚) @combine{\begin{picture}(@x[10],@y[10])(0,0) + \put(@x[2],@y[5]){\line(1,0){@x[8]}} + \put(@x[3],@y[6]){\line(1,0){@x[7]}} + \put(@x[3],@y[10]){\line(0,-1){@y[4]}} + \put(@x[2],@y[10]){\line(0,-1){@y[5]}} + \end{picture}}] + [(#\╝) @combine{\begin{picture}(@x[10],@y[10])(0,0) + \put(@x[0],@y[5]){\line(1,0){@x[8]}} + \put(@x[0],@y[6]){\line(1,0){@x[7]}} + \put(@x[7],@y[10]){\line(0,-1){@y[4]}} + \put(@x[8],@y[10]){\line(0,-1){@y[5]}} + \end{picture}}])) + + ;; ----------------------------------------