#lang scribble/base @(require racket scribble/core scribble/base scribble/html-properties) @;@(require (for-syntax amkhlv/bystroTeX/slides_for-syntax)) @;@(require amkhlv/bystroTeX/slides amkhlv/bystroTeX/common) @(require (for-syntax (planet amkhlv/bystroTeX/slides_for-syntax))) @(require (planet amkhlv/bystroTeX/common) (planet amkhlv/bystroTeX/slides)) @(require (only-in (planet jaymccarthy/sqlite) close)) @; --------------------------------------------------------------------------------------------------- @; User definitions: @(begin (set-bystro-formula-processor! bystro-conf (find-executable-path "amkhlv-java-formula.sh")) (set-bystro-formula-database-name! bystro-conf "formulas.sqlite") (set-bystro-formula-dir-name! bystro-conf "formulas") (set-bystro-formula-size! bystro-conf 25) (set-bystro-autoalign-adjust! bystro-conf 1) (set-bystro-manual-base-alignment! bystro-conf 0) ) @; --------------------------------------------------------------------------------------------------- @; This controls the single page mode: @(define singlepage-mode #f) @; --------------------------------------------------------------------------------------------------- @; it is possible to rename existing functions: @(begin (define slide bystro-slide) (define after-pause bystro-afterpause) (define remove-slide bystro-remove) (define (label s) (elemtag s (bystro-number-for-formula s))) (define (ref s) (elemref s (bystro-ref-formula s))) ) @; --------------------------------------------------------------------------------------------------- @; and define new functions: @(begin (define (red . x) (apply bystro-clr (cons "red" x))) (define (green . x) (apply bystro-clr (cons "green" x))) (define (greenbox-style more) (bystro-elemstyle (string-append "border-style:solid;border-color:#00aa00;" more))) (define (redbox-style more) (bystro-elemstyle (string-append "border-style:solid;border-color:#aa0000;" more))) (define (greenbox more . x) (elem #:style (greenbox-style more) x)) (define (redbox more . x) (elem #:style (redbox-style more) x)) (define (greenbox-wide more . x) (nested #:style (greenbox-style more) x)) (define (redbox-wide more . x) (nested #:style (redbox-style more) x)) (define (hrule) (element (make-style #f (list (alt-tag "hr"))) "")) (define (leftbar . x) (para #:style (bystro-elemstyle "border-left-style:solid;border-color:green;padding-left:12px;") x)) ) @; --------------------------------------------------------------------------------------------------- @; The basic syntax is somewhat tunable: @(define-syntax (defineshiftedformula x) (bystro-formula-syntax #:autoalign-formula-prefix "f" #:manual-formula-prefix "f" #:display-math-prefix "equation" #:size-change-notation "fsize" #:size-increase-notation "fsize+" #:size-restore-notation "fsize=" x)) @; --------------------------------------------------------------------------------------------------- @; INITIALIZATION (please do not change anything in this part!): @(unless (bystro-formula-processor bystro-conf) (error "*** could not find executable for formula processing ***")) @(define formula-database (bystro-initialize-formula-collection)) @(defineshiftedformula "formula-enormula-humongula!") @(bystro-titlepage-init #:singlepage-mode singlepage-mode) @; --------------------------------------------------------------------------------------------------- @; --------------------------------------------------------------------------------------------------- @; AND HOPEFULLY SOME CONTENT: @title{BystroTeX} Mathematical slides using the @hyperlink["http://docs.racket-lang.org/scribble/"]{@tt{scribble}} markup system Andrei Mikhailov, IFT UNESP @bystro-toc[] @slide["Inserting mathematical formulas into html slides" #:tag "MathFormulasInSlides" #:showtitle #t]{ We can insert @f{W(\phi)} as an inline formula, or a display formula: @equation[#:label "Lagrangian" ]{ {\cal L} = \left(\partial_{\mu}\phi,\partial^{\mu}\phi\right) - \left|\left| {\partial W(\phi)\over \partial\phi} \right|\right|^2 } Or, formula in the box: @bystro-longtable[#:styless @'(((center) (right))) @list[@list[@nested[@redbox["padding:36px;8px;0px;8px;"]{ @f{\dot{\phi} = - {\partial W\over \partial \phi}} }] @nested{@label{SolitonEquation}}]]] If we need, we can also insert @f-4{x^2} shifted down, or insert a shifted up and rescaled: @f+3+8{y^2}. @smaller{ @fsize+[-5] We can also temporarily change the default size of the formulas. For example, this paragraph is typeset using small font. The formula @f{yx^2} comes out smaller because we changed the default size. After we restore the default size @fsize=[] @f{zx^2} is of the normal size. } See the @seclink["Syntax"]{syntax part} for more examples. } @after-pause{ @tabular[@list[@list[@para{ Besides the math-specific task of inserting formulas, many things can be done using the @hyperlink["http://docs.racket-lang.org/scribble/"]{well documented} @tt{scribble} environment. @linebreak[] For example, one can include pictures, as illustrated. Flying kite could be an allegory for slide presentations.} @smaller-2{@(image (string->path "snapshots/kite.png") #:scale 0.5) @hyperlink["http://openclipart.org/detail/67597/child-with-a-kite-by-laobc"]{openclipart.org}}]]] } @remove-slide[] @after-pause{ @bystro-clr["red"]{ Also supported pause and removal of slides.} } @slide["Jumping to references" #:tag "JumpingReferences" #:showtitle #t]{ Remember the formula (@ref{Lagrangian})? Clicking on (@ref{Lagrangian}) brings you to that formula. It is also possible to jump to a particular slide, for example @seclink["Installation"]{jump to ``Installation''}. Sometimes you might want to press the ``up'' link, which will bring you to the title page. The title page has the list of contents, so you can jump to particular slides from there. } @slide["Installation" #:tag "Installation" #:showtitle #t]{ You should start with installing @hyperlink["http://racket-lang.org/"]{@tt{Racket}} on your computer. For example, on @tt{Debian} you should issue this command @bold{@bystro-clr["red"]{as root:}} @bystro-verb{ aptitude install racket } This command will install @tt{Racket} environment on your computer. Next you should install @tt{bystroTeX} using this command @bold{@bystro-clr["red"]{as normal user}} (i.e. @bold{@bystro-clr["red"]{not}} root): @bystro-verb{ racket -e '(require (planet amkhlv/bystroTeX/slides_setup))' } This command will take some time, because it has to download and compile things. It will talk back to you, asking some questions and giving further instructions. In particular, it will ask you to choose a folder where a sample slide presentation is stored. After the installation, @bystro-clr["red"]{go to that sample folder}. } @slide["Sample presentation" #:tag "SamplePresentation" #:showtitle #t]{ You should find that the sample folder contains (at least) the following files: @bystro-table[#:orient 'hor @list[@list[@larger["Filename"] @larger["purpose"]] @list[@tt{slides-manual.scrbl} "main source file"] @list[@tt{slide.css} "style of the regular slide"] @list[@tt{slide-title.css} "style of the title slide"] @list[@tt{misc.css} "various elements of style"] ]] The command to actually ``build'' the slideshow is: @bystro-verb|{ scribble --htmls slides-manual.scrbl }| This command may take some time when you run it for the first time. It will generate the @tt{html} files in the new folder called @tt{slides-manual}. Then you can view it in @tt{Firefox}: @bystro-verb|{ firefox slides-manual/index.html }| } @slide["Adjusting fontsizes, width and other style" #:tag "AdjustCSS" #:showtitle #t]{ Most of things are done in 2 @tt{css} files, @tt{slide.css} and @tt{slide-title.css}. The first file is for the regular slide, and the second for the titlepage. @smaller-2{@bold{@bystro-clr["red"]{Note}}: I am talking about the files in the root of the sample folder. When you @seclink["SamplePresentation"]{compile}, they get copied into the subfolder @tt{slides-manual/index.html}. Everything in that subfolder (in particular @tt{css} files) is auto-generated. Therefore, you should not edit anything there! } How to figure out which element of the slide corresponds to which section of the @tt{css} file? Firefox has the ``style inspector'' tool which reveals names. It is activated by pressing @tt{Ctrl-Shift-I}. If you press on the ``style'' tab, it will even show you from which line of the @tt{css} file came this or that element on the page! @smaller-2{(To turn it off press @tt{Ctrl-Shift-I} again.)} Notice that the width is controlled by the @tt{width} parameter of @tt{.maincolumn}. } @slide["Will it fit on the projector screen?" #:tag "FitProjector" #:showtitle #t]{ This is a very important question. Before giving a talk, try to figure out the projector resolution. (I think most of them are 1024x768.) I once got the projector replaced just before my talk, so I found myself trying to @seclink["AdjustCSS"]{edit the .css files} right in front of the audience. @smaller-2{(Nice exercise!)} Linux has a command called @tt{xte}, which can position the mouse cursor at a given point on the screen. For example: @bystro-verb|{ xte 'mousemove 1024 768' }| Maybe this can be used to check if your slide will fit. The easiest way to adjust the width of the slide is by using the @tt{width} parameter of @tt{.maincolumn}. @smaller{ Alternatively, you can change the font sizes. If you do decide to change the font sizes, you might also need to adjust the formula size in the headers of the @tt{.scrbl} file, and perhaps in the @tt|--{@fsize[]}--| function. } } @slide["Basic syntax" #:tag "Syntax" #:showtitle #t]{ You might want to read @hyperlink["http://docs.racket-lang.org/scribble/reader.html"]{basic Scribble documentation}, but it should not be necessary. Just look at the source file and proceed by analogy. To insert formula @f{x^2/y^2}, type: @bystro-verb|{@f{x^2/y^2}}| Curly brackets inside are usually not a problem: for @f{y_{ij}} just type @bystro-verb|{@f{y_{ij}}}| it works. If however something goes wrong, you might want better protection: @bystro-verb|---{@f|{y_{ij}}| or even @f|-{y_{ij}}-| }---| There is also @tt|--{@equation{...}}--| which allows formula labeling using @tt|--{@equation[#:tag "FormulaName"]{...}}--|. It is also possible to manually align the formulas, for example @tt|--{@f+4{x^2}}--| produces @f+4{x^2} and @tt|--{@f-7{x^2}}--| gives @f-7{x^2}. There is also zoomed @tt|--{@f+0+7{x^2}}--| which gives @f+0+7{x^2} and zoom with align @tt|--{@f-5+7{x^2}}--| which gives @f-5+7{x^2}. Sorry I have not implemented @tt{align/eqnarray}, in fact this may be a nontrivial task. Please use a combination of @tt|--{@tabular[]}--| and @tt|--{@f/@f+i/@f+i+j}--| for now. The command @tt|--{@fsize[20]}--| changes the formula size to 20pt, the command @tt|--{@fsize[]}--| or equivalently @tt|--{@fsize=[]}--| returns back to the previous size (but you can not nest them, there is not stack of sizes). Actually I recommend to use instead the command @tt|--{@fsize+[5]}--| which changes the size relatively to the base size. This will scale better if you will have to suddenly @seclink["FitProjector"]{change the resolution} 3 minutes before your talk. To decrease the size, use @tt|--{@fsize+[@-[5]]}--| or equivalently @tt|--{@(fsize (- 5))}--|. Both @tt|{@fsize[]}| and @tt|{@fsize+[]}| have an optional second argument, which modifies the vertical base alignment. We use @hyperlink["http://forge.scilab.org/index.php/p/jlatexmath/"]{@tt{JLaTeXMath}} to produce @tt{png} files. We had some problems with large size integral signs: @f{\int {f\over g} dt} and large size brackets: @f{\left( {x\over y} \right)}. As you can see, they come out a bit weird. It seems that this is caused by a general bug in @tt{OpenJDK} (which is the default implementation of Java on Debian). The situation is discussed @hyperlink["http://forge.scilab.org/index.php/p/jlatexmath/issues/676/"]{here}. If this becomes a problem, use @hyperlink["http://www.oracle.com/technetwork/java/javase/downloads/index.html"]{Sun JDK} instead of @tt{OpenJDK}. (The page you are reading now was prepared using @tt{OpenJDK}.) This slide is very tall and will probably go below the bottom of the display area, so you need to scroll down to read it. This is intentional. Sometimes you have to show a long list of formulas. Scrolling is easier on the audience than jumping from page to page. } @slide["Writing html in scribble" #:tag "InsertingHTML" #:showtitle #t]{ What if we want to insert, for example, a remote animated gif from @hyperlink["http://www.123gifs.eu/free-gifs"]{123gifs.eu} ? As far as I understand, there is no way to directly insert a raw @tt{html} code in scribble. Instead, we have to rewrite our @tt{html} the @hyperlink["http://docs.racket-lang.org/scribble/index.html"]{scribble way}. For example, this @tt{html}: @(element (make-style #f (list (alt-tag "img") (attributes (list (cons 'style "border:0;") (cons 'src "http://www.123gifs.eu/free-gifs/flags/flagge-0544.gif") (cons 'alt "flagge-0544.gif from 123gifs.eu") )))) "Flag of Brazil" ) @bystro-verb|{ flagge-0544.gif from 123gifs.eu Flag of Brazil }| will become: @bystro-verb|--{ @(element (make-style #f (list (alt-tag "img") (attributes (list (cons 'style "border:0;") (cons 'src "http://www.123gifs.eu/free-gifs/flags/flagge-0544.gif") (cons 'alt "flagge-0544.gif from 123gifs.eu") )))) "Flag of Brazil" ) }--| } @slide["Notes for emacs users" #:tag "Emacs" #:showtitle #t]{ If you use @tt{emacs}, I would highly recommend installing the @tt{emacs} scripts from @hyperlink["http://www.neilvandyke.org"]{www.neilvandyke.org}. Not as powerful as @hyperlink["http://www.gnu.org/s/auctex/"]{AUCTeX}, but still very cool! Some more staff in @tt{.emacs}, if you wish: @bystro-verb|--{ (add-outline 'scribble-mode-hook) (add-hook 'scribble-mode-hook '(lambda () (setq outline-regexp "@section\\|@subsection\\|@subsubsection\\|@slide"))) (defface scribble-slide-face '((((class color) (background dark)) (:inherit variable-pitch :family "Terminus" :foreground "khaki2" :weight bold :height 1.2))) "Basic face for highlighting the scribble slide title.") (add-hook 'scribble-mode-hook '(lambda () (font-lock-add-keywords 'scribble-mode '(("@slide\\[\"\\(.*?\\)\".*\\]" 1 'scribble-slide-face prepend) ("@slide\\[@elem{\\(.*?\\)}.*\\]" 1 'scribble-slide-face prepend) ("@\\(after-pause\\)" 1 'font-lock-warning-face prepend) ("@\\(slide\\)" 1 'font-lock-warning-face prepend))))) }--| --- for more syntax highlighting } @slide["Sections in slide" #:tag "Sections" #:showtitle #t]{ @table-of-contents[] @section{Introduction} A slide can contain sections @section{Disadvantages} Obviously, this is a bad idea when giving a talk. @section{Advantages} But it could be good for something else. } @slide["Single page and printing" #:tag "SinglePage" #:showtitle #t]{ It is also possible to have everything on one single long @tt{html} page. This is useful, for example, for @red{printing}. For that, two things have to be done: @itemlist[#:style 'ordered @item{Change @tt|{@(define singlepage-mode #f)}| to @tt|{@(define singlepage-mode #t)}| in the headers of your @tt{.scrbl} file} @item{Different method of compilation. Instead of compiling as we explained @seclink["SamplePresentation"]{here}, do this: @itemlist[#:style 'ordered @item{Create new directory: @bystro-verb{mkdir singlepage}} @item{Now compile: @bystro-verb|{scribble --dest singlepage slides-manual.scrbl}| }]}] } @slide["Troubleshooting" #:tag "Troubleshooting" #:showtitle #t]{ @bystro-table[#:orient 'hor @list[ @list[ @para{Something is very wrong} @para{Check if the @tt{singlepage-mode} parameter is set up correctly in the headers, as explained @seclink["SinglePage"]{here}.} ]@list[ @para{Some formulas look ugly} @para{Use Sun Java as explained @seclink["Syntax"]{here}}] @list[ @para{Execution of the command ``@tt{scribble ...}'' freezes} @para{If your talk has many formulas, and this is the first time you are executing the @tt{scribble} command, you may need to wait 1 min or so... But sometimes it, really, freezes. This may happen on slow machines. Do the following: @linebreak[] 1. Stop @tt{scribble} (just @tt{Ctrl-C}) @linebreak[] 2. @tt{rm bystrotex.fifo} @linebreak[] 3. @tt{rm formulas.sqlite} @linebreak[] 4. @tt{rm formulas/*} @linebreak[] 5. @tt{pkill -n java} @linebreak[] 6. Start your @tt{scribble} command again } ] ]] } @slide["Under the hood" #:tag "UnderTheHood" #:showtitle #t]{ @image{svg/under-the-hood.svg} The @bold{backend} can be replaced with any program which has the following properties: @itemlist[#:style 'ordered @item{It should wait on @tt{stdin} for a text string of the form: @bystro-verb|{ \sum_{n>0} {x^n\over n} }| --- this is called ``@hyperlink["http://en.wikipedia.org/wiki/XML"]{XML}'' } @item{Upon the receipt of such a text string, it should do two things: @itemlist[ @item{Write the picture of the formula in the @tt{png} format to @tt{formulas/3.png}} @item{Print on @tt{stdout} the text like this: @bystro-verb|{ 7 }| which reports the depth (@italic{i.e.} vertical offset) of the formula} ]} ] The name of such a program (in our case it is @tt{amkhlv-java-formula.sh}) should be specified at the top of the slides header in this line: @bystro-verb|{ (set-bystro-formula-processor! bystro-conf (find-executable-path "amkhlv-java-formula.sh")) }| Our backend which we are using contains a @hyperlink["http://www.linuxjournal.com/article/2156"]{Linux pipe}, which prevents it from being used on Windows. } @slide["Why not Beamer?" #:tag "Beamer" #:showtitle #t]{ There is an excellent tool called @hyperlink["http://en.wikipedia.org/wiki/Beamer_(LaTeX)"]{Beamer}, which is based on @tt{LaTeX} and can be used with @hyperlink["http://www.gnu.org/s/auctex/"]{AUCTeX}. The problem is, I don't like @tt{TeX} and @tt{LaTeX}. This is, of course, a matter of personal preference. Also, Scribble produces @tt{.html} files. I find @tt{.html} format more convenient for giving presentations than the @tt{Beamer}'s format @tt{.pdf}. @elem[#:style @bystro-elemstyle["text-decoration:blink;"]]{Most importantly: Beamer won't give you blinking text.} } @slide["From TeX to HTML" #:tag "FromTeXtoHTML" #:showtitle #t]{ Seriously, @redbox["padding:8px;8px;8px;8px;"]{ @larger{I think that we should switch from TeX to HTML} } @itemlist[ @item{TeX is optimized for the quality of typesetting. This is not very important for us.} @item{HTML is all about @boldred{creating links}. This is exactly what we need. After all, scientific publishing is for @boldred{linking} ideas.} @item{Practically, TeX is very hard to learn, and hard to use properly. With the right markup tools (perhaps this project?) HTML should be easier.} @item{Learning the syntax of LISP (@hyperlink["http://racket-lang.org/"]{Racket}) is pleasure. The syntax of TeX/LaTeX is pain.} ] } @close[formula-database]