Hi all, I had a hard time to get any equations into my scribble document, as writing
\begin{equation*} f(x) = x^2 \end{equation*} would be turned into "$\backslash$begin...", which meant that it wouldn't actually show up as an equation but as garbage text with "begin{equation*}" and so on showing up. Since I found a way of getting it to work, I wanted to document it in baby steps that my 2-hours younger self would have understood faster than the links I found. Plus, I may be missing even easier solutions. The first problem with regards to equations in Latex is that Scribble (understandably) escapes some characters such as \ and $, so that Latex never sees the \begin, but $\backslash$. The second is to tell Scribble to load the Latex packages amsmath and amssymb. The solution to the first is to use Prabhakar Ragde's solution (see an example of it at https://gist.github.com/spdegabrielle/c9c9964d3e2fb4faa268). To get equation* working for instance, make a new file math.rkt (works for Latex only, for HTML see end of email, also from the above github link): ---- #lang racket/base (require scribble/base scribble/core) (provide equation*) (define (mymath start end . strs) (make-element (make-style "relax" '(exact-chars)) `(,start ,@strs ,end))) (define (equation* . strs) (apply mymath "\\begin{equation*}" "\\end{equation*}" strs)) ---- I still do not understand why I have to type "\\" rather than "\". I get that something somewhere is escaping the backslash. I am uncomfortable with this, as it seems that "{" and "}" are not escaped, but since I do not know what is and what isn't, I may at some point in the future get a cryptic error message because I used a command or a character in the strings that gets unescaped. Anway, once I do this, I can require math.rkt in my .scrbl file: ---- #lang scribble/base @(require "math.rkt") ; Assumes math.rkt is in the same folder as .scrbl file @title{Scribbling Equations} @section{Equations at Work} @equation*{f(x) = x^2} ---- To solve the second problem, make a new prefix file, math-prefix.tex: --- \documentclass{article} \usepackage[utf8]{inputenc} ; from standard prefix file \usepackage[T1]{fontenc} ; from standard prefix file \usepackage{amsmath} ; Required for equation* \useapackage{amssymb} ; Required for a bunch of mathematical symbols --- Finally, run the following on the command line: scribble --prefix math-prefix.tex --pdf equations.scrbl This worked for me. Is this the right way of loading extra packages? And when defining new mathematical commands in this way, what characters that might get escaped do I have to worry about? As for getting it to work with HTML, one should add the following to the math.rkt file: --- #lang racket/base ; From http://con.racket-lang.org/pr-slides.pdf ; by Prabhakar Ragde (require scribble/html-properties ; THIS IS NEW scribble/base scribble/core) (provide ...) ; ADD THIS: It defines the link to MathJax, a library which turns Latex math ; into proper form on websites (define mathjax-source "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" ) ; By using @setup-math in your .scrbl file, this loads the mathjax library (define setup-math (paragraph (style #f (list (alt-tag "script") (attributes `((type . "text/javascript") (src . ,mathjax-source ))))) '())) --- Thanks for reading this far. And just to be clear, I am not taking credit for this solution, but I found the existing links to be unclear, and only addressing one part of the problem, which meant that I wasn't even sure what went wrong when it did. Hope this helps someone. Cheers, Marc -- 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.