szhorvat / MaTeX

LaTeX labels in Mathematica
http://szhorvat.net/mathematica/MaTeX
MIT License
375 stars 45 forks source link

Exporting figures in the correct size, using remote kernel. #36

Closed phyjswang closed 3 years ago

phyjswang commented 3 years ago

Dear szhorvat,

First of all, thank you for your work on this wonderful MaTeX package!

Here is a tricky problem I encountered recently: I use a remote linux kernel to produce some large-size data (which prevent me from doing what follows completely from a local machine), then using local frontend to make some beautiful figures with MaTeX.

When try to export these figures:

  1. I can't export to pdf format using the local frontend with remote kernel, as also being mentioned in this stackexchange page, I guess this is a bug of MMA not been fixed yet.

  2. I then write a .wls file, and run it using ssh on the remote linux. This way indeed generate the .pdf file, but they are not in the correct imagesize, since the command

SetOptions[$FrontEndSession, PrintingStyleEnvironment -> "Working"]

you mentioned in tutorial can not work. In fact, the error message is

FrontEndObject::notavail: A front end is not available; certain operations require a front end.

Thus, the problem "Due to a quirk in how Mathematica handles plot legends, we must set one additional option to avoid shrinking legended plots at the time of export" can not be prevent.

Is there a way to fix this issue?

Best, JW

szhorvat commented 3 years ago

I would recommend exporting on the remote machine. Local FE / remote kernel tends to be problematic. I gave up completely on trying to use it.

Whenever you get FrontEndObject::notavail, try wrapping the offending command in UsingFrontEnd. Hopefully this should work on the remote machine.

phyjswang commented 3 years ago

I would recommend exporting on the remote machine. Local FE / remote kernel tends to be problematic. I gave up completely on trying to use it.

Whenever you get FrontEndObject::notavail, try wrapping the offending command in UsingFrontEnd. Hopefully this should work on the remote machine.

Thank you for the UsingFrontEnd trick, it works perfectly!