1

Update

ConfigureMaTeX[
    "pdfLaTeX" -> 
    "C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64", 
    "Ghostscript" -> "C:\\Program Files\\gs\\gs9.23\\bin"
]

CAN NOT work!!!! Help manual is misleading in this case. But I suppose the author only uses MAC OS and could not test it.

ConfigureMaTeX[
    "pdfLaTeX" -> 
    "C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64\\pdflatex.exe", 
    "Ghostscript" -> "C:\\Program Files\\gs\\gs9.23\\bin\\gswin64c.exe"
]

Finally worked for MaTeX. But the main problem still remains.

I want to do something similar to here,

myplot[a_, b_] :=   Plot[a*Sin[b*x], {x, -Pi, Pi},    PlotLabel ->     TeXForm["$a=" <> ToString[a] <> ", b=" <> ToString[b] <> "$"]];
myplot[5, 4]

Does not work.

Also tried something like this,

myplot2[a_, b_] :=   Plot[a*Sin[b*x], {x, -Pi, Pi},    PlotLabel ->     ToExpression["k=" <> ToString[a] <> ", n=" <> ToString[a],      TeXForm, HoldForm]];
myplot2[5, 4]

and lots of variations. None worked.

enter image description here

Or keep getting error messages,

ToExpression::esntx: Could not parse k=5, n=5 as input.

GhostScript (can't not configure properly)

enter image description here enter image description here

Chen Stats Yu
  • 4,986
  • 2
  • 24
  • 50
  • 2
    you need to install MaTeX? TeXForm byitself does nothing. It just gives the latex representation of a Mathematica expression. To render it, you need to compile the latex, which is what MaTeX does. – Nasser Jul 17 '18 at 08:37
  • @Nasser hmmm, tried it once. Seemed pretty difficult to setup. I have MikTeX on system, which supports GhostScript. but MaTeX still couldn't use it. – Chen Stats Yu Jul 17 '18 at 08:42
  • @Nasser I even give the full path C:\Program Files\gs\gs9.23\bin which contains gswin64c.exe. and it still says not properly configured ... very annoying. – Chen Stats Yu Jul 17 '18 at 08:50
  • there's very detailed documentation--hope you used the doc centre as instructed. I really dont know how to make config instructions any clearer. Specific suggestions for improvrments always welcome but please do read the config tutorial in full first – Szabolcs Jul 22 '18 at 17:11
  • open doc centre and search for "matex" then see the configuring matex link. Suggestions will be incorporated into next version to make things easier – Szabolcs Jul 22 '18 at 17:14
  • @Szabolcs not sure what you are referring to here. But regarding the configuration, the manual only says about the folder, which does not work on windows machines, it has to link to the specific EXE file, instead of the folder containing it ( which is what the manual says ) – Chen Stats Yu Jul 22 '18 at 17:18

1 Answers1

1

Install tex2im (have a look a the [options]), then use this function

showTeX:=Import@ReadString["!tex2im -f png -o "<>#1<>" '"<>#2<>"';echo -n "<>#1]&[CreateFile[],First@#]&

with a TextCell as input, i.e. press Ctrl+9 and put your TeX commands that yellow/orange background box. In this way you won't have to bother with the escape characters that might be present in your TeX string. For instance, the FullForm of your input might be

showTeX[TextCell["\\sum_{n=0}^2 \\beta_n"]]

enter image description here

By pressing Ctrl+9 you do not need type those double backslashes "\"

Regarding your specific issue, showTeX@TeXForm[..] works as well because TeXForm is a wrapper similarly to TextCell.

myplot2[a_,b_]:=Plot[a*Sin[b*x],{x,-Pi,Pi},PlotLabel->showTeX@TeXForm["k="<>ToString[a]<>", n="<>ToString[a]]];
myplot2[5,4]

enter image description here

Fortsaint
  • 2,060
  • 15
  • 17