
I’m considering writing my first slideshow presentation. The tutorial did not show any way to typeset math notation. Has anyone ever produced anything like that? I believe @soegaard2 might have solved this problem already, but perhaps it was just for Scribble.


That’s nice! Though a first problem I see is that it assumes a UNIX-default installation of LaTeX. I’ll have to find a way to set the latex executable somewhere else.

My version is here: https://docs.racket-lang.org/latex-pict/index.html
If my memory is correct, slideshow-latex produces pngs that are inserted. On the other hand latex-pict produces a standard pict (so you can scale and rotate).
I think both solutions have parameters that control where to find latex.

I am using:

to find where latex
is.

I think I have bigger problems here. When I try to load the latex-pict library, I find that libintl–8.dll is 32-bit and not 64-bit as most likely your poppler library needs. ;
; Welcome to Racket v7.9 [bc].
; On-demand, one-time instantiation of racket/gui/base.
; ffi-lib: couldn't open "libintl-8.dll" (%1 is not a valid Win32 application.; errid=193)
>
My GNU Emacs is actually 64-bit, but I need to upgrade my MinGW to a 64-bit version. My libintl–8.dll is currently 32-bit because of MinGW. %file libintl-8.dll
libintl-8.dll: PE32 executable (DLL) (console) Intel 80386, for MS Windows

If I recall correctly, libintl is shipped with Racket.

So your PATH must be setup to find the MinGW one first?

According to the link below, it ought to be libintl–9 ? https://github.com/racket/draw/blob/master/draw-lib/racket/draw/unsafe/cairo-lib.rkt#L20

Suuuuuper random, but isn’t (cond [test => (lambda (p) p)])
just (cond [test => identity])
?

Perhaps he didn’t want to require racket/function
?

Ah; I thought identity
was in even racket/base

I also think it should. :smile:

It’s actually just (cond [test])
:slightly_smiling_face:

Sometimes I write values
instead of identity
.

I think values can be better optimized than identity, as identity needs to check that there’s only one value

@soegaard2 Your package worked on my Windows 10 system right out of the box actually. I switched from msys–32-bit to msys–64-bit. (A bit of revolution in my system.) Your package must have found pdflatex on my PATH and it just worked. (It even installed preview all by itself, or miktex did.) Very nice. Thank you so much for your assistance!


The LaTeX error was that the mirror I used to use was gone. I had to change it.

Great to hear it worked.

Maybe slidewhow-latex
works too, now?

You’re also right on that! Running it from racket-mode, though, the slideshow GUI application runs and I even saw the first slide flash on the screen, but what I see now is just a blank fullscreen. But that’s not a problem. All I want the ability to create pictures from LaTeX code. Thanks so much!

Of course, from DrRacket everything works as expected.

@soegaard2 I believe metapict/tex is gone. Your https://docs.racket-lang.org/latex-pict/index.html\|examples still require metapict/tex. I guess it should be (require latex-pict).

@anything Thanks - You are right.

@soegaard2 I’m using your latex-pict successfully. However, with slideshow.exe --print slides.rkt
I generate a PDF that comes out without the math expressions. They display fine with slideshow GUI, but they appear not to be included in the PDF. Can you spot what I’m doing wrong?

@anything Hmm. Didn’t know about that issue. I’ll need to look into how slideshow generates the pdf.

A way around it, is to convert the picts into bitmaps with pict->bitmap
(I think that’s the name), but it would be more elegant without.

That is, I think the problem is the interaction between slideshow and latex-pict, not your code.

Okay, thanks! I don’t need the feature right now. I’m planning to use slideshow.exe soon. It’s nice to have the PDF so we can take the presentation on a usb-stick and go mobile. I’m happy enough to be able to understand a minimum of the code here. I can’t stand powerpoint and LaTeX isn’t as nice as Racket.

This snippet from racket-poppler
is clearly wrong. But I can’t remember whether I did this on purpose…

@anything I have pushed a (untested) change. The package server will soon pick it up:

Thank you! That’s a privilege! I appreciate it!

Let me know if it works.

It doesn’t appear to have worked. I did update the package. My new version is: latex-pict 847bd5f42903fa... catalog...ict.git
Here’s a <https://pastebin.com/raw/vadR1Tqw|sample program>. The PDF is attached. It displays fine using slideshow.exe.

Can you send me a test file?

Yes, it’s that “sample program” link above. Here’s the full URL: https://pastebin.com/raw/vadR1Tqw

How it displays through slideshow.exe:

The plot thickens, no matter how I run slideshow (DrRacket, racket-mode, terminal), I can’t see the formulas.

I am on macOS btw.

In the terminal I see:

When I no error messages at all in the terminal when I run it.

But … slideshow —pdf test-slides.rkt works for me !?!

I run it, it a GUI window pops up asking for paper size (from the print driver, I think), portrait, landscape, then the print dialog comes up and I save it to a PDF. The program then ends and the PDF is generated. %slideshow --print print-latex-pict.rkt
%

From my pdf :

Oh, there is —pdf? I didn’t even know!

It did not work for me. Same result, curiously.

I still see a dialog (from Windows, likely the printer driver) asking me paper size, … It’s different from the other, but similar. Curious. But, anyway, the result is the same.


I’ll see if it works with newer versions too.

Hm. I’m running Racket 7.9 here.

8.0 here - but I must have forgotten to change the path

In version 8.0 I get

in the pdf

Interesting.

In Racket 7.7 BC I get:

And the same result in 7.7 CS.

This is from slideshow/viewer.rkt:

Maybe - this explains why I see different results (since I am on macOS).

I am not sure though.

Thanks for looking into it, though!

I guess the solution for now, is to convert to bitmaps. The downside is that the resulting pdfs aren’t as zoomable :disappointed:

I am 99% sure that the problem has something to do with racket-poppler rendering directly to a cairo context.

But exactly where things go wrong? No idea.

Where would I put the call to pict->bitmap? As an emergency-workaround, it’s not bad at all.

#lang at-exp slideshow
(require latex-pict)
(define ($ s) (scale (bitmap (pict->bitmap (scale (tex-math s) 4))) 1/4))
(define ($$ s) (scale (bitmap (pict->bitmap (scale (tex-display-math s) 4))) 1/4))
(define ($$$ s) (scale (bitmap (pict->bitmap (scale (tex-real-display-math s) 4))) 1/4))
(slide #:title "A title"
@t{Some text}
(hbl-append (t "We have ")
($ "2^{256}")
(t " options for you.")))

By the way, Jay McCarthy and Neil Toronto’s slideshow/latex does work here. Here’s a sample, very similar: https://pastebin.com/raw/Cgz8xm8q Attached a resulting PDF and how it displays for me.

When viewed as a slideshow it looks fine. But if you zoom in on the pdf, you’ll see:

That’s a pretty nice workaround. Thanks! It works here. Zooming in seems to work pretty well actually.

The “fix” above has the same problem.

Notice the result on my system is a lot better than yours. Check it out. This is SumatraPDF on a Windows 10.

From your pdf?

Yes.

huh?

I ran your sample program with slideshow --pdf bitmap-solution.rkt
and opened the PDF with SumatraPDF on a Windows 10 system.

I can see the imperfections, but it’s much smoother than your sample picture above.

Oh. I thought you meant it was with slideshow/latex .

The scale factor 4 determines how much you can zoom.

Here’s the zoom with slideshow/latex. It’s much worse. So your bitmap solution is a lot better, actually.

Well, I think you can do the same with slideshow/latex.

@bkwok_77 has joined the channel