2

Requires MaTeX, which can be found here.

<< MaTeX`

myplot[k_: 5, n_: 10] := Plot[k*Sin[n*x], {x, -2 Pi, 2 Pi}    , PlotLabel ->     MaTeX["k=" <> ToString[k] <> ", n=" <> ToString[n],      Magnification -> 1.5]];
myplot[]

Works fine. enter image description here

But if I export the PDFs using ParallelTable,

ParallelTable[ Export[ToString[n] <> ".pdf",    myplot[RandomReal[{-3, 3}], RandomInteger[{1, 5}]]], {n, 1,    30}] // AbsoluteTiming

The labels fail to work.

enter image description here

Anyone had similar problems ? Solutions?

Chen Stats Yu
  • 4,986
  • 2
  • 24
  • 50
  • As mentioned in Details of ParallelTable: The default value is DistributedContexts:>$DistributedContexts with $DistributedContexts:=$Context, which distributes definitions of all symbols in the current context, but does not distribute definitions of symbols from packages. So DistributedContexts->All should work. – xzczd Jul 17 '18 at 17:15
  • @xzczd I looked at the Help and did DistributedContexts->All, didn't work. – Chen Stats Yu Jul 17 '18 at 17:54
  • @xzczd I think it might have something to do with LaTeX rather than MaTeX. – Chen Stats Yu Jul 17 '18 at 17:57
  • Without MaTeX: PlotLabel -> showTeX@TeXForm["k=" <> ToString[k] <> ", n=" <> ToString[n]], with showTeX discussed here https://mathematica.stackexchange.com/questions/178440/texform-as-plotlabels-configuring-ghostscript/178467#178467 – Fortsaint Jul 17 '18 at 20:17
  • You need to explicitly load packages on parallel kernels if you want to use thrm. See ParallelNeeds. I can't type well due to a wrist problem so no full answer--sorry – Szabolcs Jul 22 '18 at 17:09
  • @Szabolcs Thanks and Take care! – Chen Stats Yu Jul 22 '18 at 17:11

0 Answers0