On Dec 16, 2015, at 11:46 PM, tachlithavayati wrote:
> Hi Friends:
>
> With minlatex.rkt functions I can successfuly render HTML with LaTeX in
> one-page documents (directly from DrRacket or with Scribble --html). But for
> multi-page options, for example with Scribble --htmls, the render is
> something like:
>
> \[e^{i \pi}+1=0\]
>
> Question: Is there a way to render multi-page HTML with LaTeX code?
>
> Thank you in advance for any hint concerning this problem.
>
> Sincerely, Enrique Comer
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
I am not sure what you mean with 'rendering latex with htmls'. I am writing
HtDP/2e with latex embedded and I use the equivalent of --htmls. The code is
below. When it is in 'latex' mode, I generate real latex math; when it is html
mode, it creates PDFs that are included.
#lang at-exp racket/gui
(provide
;; [#:file (f String)] String *-> ImageSnip
;; (latex s ..) runs latex on s ... and turns the result into an image snip
;; if #:file is specified it also saves a version of the image in a file
latex
;; -> Real
latex-scale
;; -> Boolean
in-latex-mode?)
;;
---
;; IMPLEMENTATION
(require scribble/core)
(define (in-latex-mode?)
(define v (map string->symbol (vector->list
(current-command-line-arguments
(member 'latex v))
(define (latex-scale)
(if (in-latex-mode?) 0.75 1.0))
(define (latex #:display [display-style #false] #:file (f "x") . strs)
(define math-delimiters (if display-style "$$" "$"))
(define the-math (string-append math-delimiters (string-append* strs)
math-delimiters))
(define x.tex (string-append f ".tex"))
(define x.pdf (string-append f ".pdf"))
(define x.png (string-append f ".png"))
(define cmd (regexp-replace #rx"\n+" (COMMANDS x.tex x.pdf x.png) " \\&\\& "))
(define latex/x (string->path "Latex/"))
(define in-latex-mode (in-latex-mode?))
(define (run)
(parameterize ([current-directory latex/x]
[current-input-port (open-input-bytes #"")]
[current-output-port (open-output-string)])
(call-with-output-file* x.tex #:exists 'truncate
(lambda (o) (fprintf o TEMPLATE the-math)))
(unless (system cmd)
(display (get-output-string (current-output-port)) (current-error-port))
(error 'latex "commands did not run successfully, see above output;
check convert"))
(begin0
(make-object image-snip% x.png 'png/mask)
#;
(rename-file-or-directory x.pdf (string-append "../" x.pdf) #t
; (define (cleanup) (delete-directory/files latex))
(if in-latex-mode
(exact the-math)
(dynamic-wind void run void)))
(define ((mk-latex-command n #:style [style '(exact-chars)]) . items)
(make-element (make-style n style) items))
; (define lpara (mk-latex-command "paragraph"))
(define exact (mk-latex-command #f))
(define TEMPLATE
@string-append{
\documentclass[preview]{standalone}
% \usepackage[mathletters]{ucs}
% \usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\pagestyle{empty}
\begin{document}
~a
\end{document}})
(define (COMMANDS x.tex x.pdf x.png)
@string-append{
pdflatex @x.tex
convert -density 90 @x.pdf -quality 90 -transparent white -trim +repage
@x.png})
@;latex{\sum_{i=0}^{\infty}\lambda_i}
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.