With a bit more experimentation, I found that pdflatex has a dvi format file output option, and there is also a utility dvipng (also part of the TexLive distribution) that converts dvi files to png graphics files. So, I've now got the shell generating and importing the png from LaTeX markup code. The png file is much easier to deal with.
Function LaTeX2pic(mTxt As String, res As Integer) as Picture
'Convert a LaTeX format math formula string to a picture
'mTxt is the LaTeX text
'res is the required picture resolution in dpi
'Uses a shell to call pdflatex and dvipng commands
'which are part of the MacTex/TexLive distributions
'
'cmdPath is the path to the directory of the Tex commands.
'Depending on which Tex distribution and which hardware/OS platform
'is used this line may need to be changed.
dim cmdPath As String = "/usr/local/texlive/2018/bin/x86_64-darwin/"
dim f As FolderItem = SpecialFolder.ApplicationData.Child("MyAppStuff")
if not f.Exists then
'Create Application Support/MyAppStuff folder if it doesn't already exist.
f.CreateAsFolder
end if
dim sPath As String = f.NativePath
Dim My_Shell As New Shell
My_Shell.TimeOut=-1
Dim theShellCode As String = "cd """+sPath+""""+EndOfLine
theShellCode = theShellCode + cmdPath+"pdflatex -output-format=dvi <<<'"
theShellCode = theShellCode + "\documentclass[12pt]{slides}"+EndOfLine
theShellCode = theShellCode + "\usepackage{geometry}"+EndOfLine
theShellCode = theShellCode + "\usepackage{lingmacros}"+EndOfLine
theShellCode = theShellCode + "\usepackage{tree-dvips}"+EndOfLine
theShellCode = theShellCode + "\usepackage[usenames]{color} %used for font color"+EndOfLine
theShellCode = theShellCode + "\usepackage{amssymb} %maths"+EndOfLine
theShellCode = theShellCode + "\usepackage{amsmath} %maths"+EndOfLine
theShellCode = theShellCode + "\usepackage[utf8]{inputenc} %useful to type directly diacritic characters"+EndOfLine
theShellCode = theShellCode + "\geometry{papersize={8.5in,1.5in}}"+EndOfLine
theShellCode = theShellCode + "\begin{document}"+EndOfLine
'Insert latex math code here. Warning: It must not contain any single quote characters.
theShellCode = theShellCode + mTxt+EndOfLine
'End of math code
theShellCode = theShellCode + "\end{document}'"+EndOfLine
theShellCode = theShellCode + cmdPath+"dvipng -bg Transparent -D "+str(res)+" texput.dvi"+EndOfLine
My_Shell.Execute theShellCode
'If everything went according to plan, there should be a png file in the app's app support folder.
dim picFile As FolderItem = f.Child("texput1.png") 'default png file name
If picFile <> Nil Then
Dim pic As Picture
pic = Picture.Open(picFile)
'Optionally, place the picture directly in the window with either of the following commands uncommented:
'ImageWell1.Image = pic
'Canvas1.Backdrop = pic
Return pic
Else
'Error - Couldn't open picFile
return nil
End If
End Function
I'm sure there's probably a way to set up the command search path so that it's not necessary to use the full path to the commands, but I'm not familiar enough with Unix to know how to do this.