anything
2021-3-10 13:07:18

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.



anything
2021-3-10 13:48:37

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.


soegaard2
2021-3-10 14:15:30

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.


soegaard2
2021-3-10 14:18:22

I am using:


soegaard2
2021-3-10 14:18:44

to find where latex is.


anything
2021-3-10 14:47:00

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


soegaard2
2021-3-10 15:08:24

If I recall correctly, libintl is shipped with Racket.


soegaard2
2021-3-10 15:08:45

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


soegaard2
2021-3-10 15:10:46

ben.knoble
2021-3-10 15:42:28

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


anything
2021-3-10 15:45:51

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


ben.knoble
2021-3-10 15:47:08

Ah; I thought identity was in even racket/base


anything
2021-3-10 15:47:46

I also think it should. :smile:


laurent.orseau
2021-3-10 15:51:12

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


soegaard2
2021-3-10 16:07:32

Sometimes I write values instead of identity.


laurent.orseau
2021-3-10 16:15:52

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


anything
2021-3-10 16:52:20

@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!


anything
2021-3-10 16:52:28

anything
2021-3-10 16:52:51

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


soegaard2
2021-3-10 16:54:33

Great to hear it worked.


soegaard2
2021-3-10 16:55:01

Maybe slidewhow-latex works too, now?


anything
2021-3-10 17:02:46

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!


anything
2021-3-10 17:03:17

Of course, from DrRacket everything works as expected.


anything
2021-3-10 17:38:57

@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).


soegaard2
2021-3-10 17:40:59

@anything Thanks - You are right.


anything
2021-3-10 19:19:12

@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?


soegaard2
2021-3-10 19:32:13

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


soegaard2
2021-3-10 19:32:56

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.


soegaard2
2021-3-10 19:34:20

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


anything
2021-3-10 19:38:15

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.


soegaard2
2021-3-10 19:47:33

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


soegaard2
2021-3-10 19:54:09

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


anything
2021-3-10 19:55:19

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


soegaard2
2021-3-10 19:56:21

Let me know if it works.


anything
2021-3-10 20:05:59

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.


soegaard2
2021-3-10 20:06:22

Can you send me a test file?


anything
2021-3-10 20:06:53

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


anything
2021-3-10 20:08:22

How it displays through slideshow.exe:


soegaard2
2021-3-10 20:12:42

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


soegaard2
2021-3-10 20:12:47

I am on macOS btw.


soegaard2
2021-3-10 20:12:58

In the terminal I see:


anything
2021-3-10 20:14:31

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


soegaard2
2021-3-10 20:15:29

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


anything
2021-3-10 20:15:44

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 %


soegaard2
2021-3-10 20:15:49

From my pdf :


anything
2021-3-10 20:16:00

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


anything
2021-3-10 20:16:52

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


anything
2021-3-10 20:17:29

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.


soegaard2
2021-3-10 20:17:33

soegaard2
2021-3-10 20:17:48

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


anything
2021-3-10 20:18:05

Hm. I’m running Racket 7.9 here.


soegaard2
2021-3-10 20:18:29

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


soegaard2
2021-3-10 20:19:32

In version 8.0 I get


soegaard2
2021-3-10 20:19:43

in the pdf


anything
2021-3-10 20:20:39

Interesting.


soegaard2
2021-3-10 20:22:24

In Racket 7.7 BC I get:


soegaard2
2021-3-10 20:25:43

And the same result in 7.7 CS.


soegaard2
2021-3-10 20:31:56

This is from slideshow/viewer.rkt:


soegaard2
2021-3-10 20:32:29

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


soegaard2
2021-3-10 20:32:56

I am not sure though.


anything
2021-3-10 20:43:11

Thanks for looking into it, though!


soegaard2
2021-3-10 20:43:52

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


soegaard2
2021-3-10 20:44:46

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


soegaard2
2021-3-10 20:45:58

But exactly where things go wrong? No idea.


anything
2021-3-10 20:47:23

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


soegaard2
2021-3-10 20:51:47

#lang at-exp slideshow (require latex-pict) (define ($ s) (scale (bitmap (pict-&gt;bitmap (scale (tex-math s) 4))) 1/4)) (define ($$ s) (scale (bitmap (pict-&gt;bitmap (scale (tex-display-math s) 4))) 1/4)) (define ($$$ s) (scale (bitmap (pict-&gt;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.")))


anything
2021-3-10 20:53:52

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.


soegaard2
2021-3-10 20:55:37

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


anything
2021-3-10 20:55:52

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


soegaard2
2021-3-10 20:55:54

The “fix” above has the same problem.


anything
2021-3-10 20:57:02

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


soegaard2
2021-3-10 20:57:23

From your pdf?


anything
2021-3-10 20:57:27

Yes.


soegaard2
2021-3-10 20:57:30

huh?


anything
2021-3-10 20:58:01

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


anything
2021-3-10 20:58:42

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


soegaard2
2021-3-10 20:58:44

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


soegaard2
2021-3-10 20:59:20

The scale factor 4 determines how much you can zoom.


anything
2021-3-10 20:59:52

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


soegaard2
2021-3-10 21:00:29

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


bkwok_77
2021-3-11 03:44:28

@bkwok_77 has joined the channel