# Problem with exporting PlotLabel using MaTeX in Parallel computation

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.

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.

Anyone had similar problems ? Solutions?

• 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 mathematica.stackexchange.com/questions/178440/… – 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