LaTeX forum ⇒ Math & ScienceTerminal commands on MacOS to access Latex

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
bob000
Posts: 7
Joined: Thu Mar 19, 2009 10:04 pm

Terminal commands on MacOS to access Latex

Postby bob000 » Thu Nov 28, 2019 8:31 am

Is it possible to use the Terminal program (or other command shell) in MacOS to send a Latex math expression string to Latex to generate a small graphic file with the formatted expression?

I'm writing a program that does numerical integration, where the user enters the expression to be integrated. I thought it would be nice to convert the user entered expression into a nice graphic that could be displayed. I've already created the code that converts a standard computer type math expression into a string of Latex code. Now I need to create the graphic. I can run a system shell from my program as long as I know the proper Unix command(s) to execute.

(Or if I can be pointed to the appropriate documentation where this is explained, that would be great.)

User avatar
Johannes_B
Site Moderator
Posts: 4098
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Thu Nov 28, 2019 9:26 am

The command simply is pdflatex.
The standalone class might also be useful.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

bob000
Posts: 7
Joined: Thu Mar 19, 2009 10:04 pm

Postby bob000 » Sat Nov 30, 2019 6:42 am

Thank you. I've got this working now, but I'm finding that the pdf file that is produced by pdflatex is difficult to work with in the application that I'm writing. Are there any other tools in the MacTex distribution that can create a simple graphics file such as png? I know that LatexIt can produce a number of different graphics files, but it doesn't appear to be possible to run LatexIt from the command line.

User avatar
Johannes_B
Site Moderator
Posts: 4098
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sat Nov 30, 2019 7:00 am

I bet you can run it from command line. TeX will output a dvi file, or a pdf file. It will never generate a png file. Everytime you see TeX generate a png file, a command like imagemagick was run in the background before.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

bob000
Posts: 7
Joined: Thu Mar 19, 2009 10:04 pm

Postby bob000 » Sat Nov 30, 2019 7:43 am

Thanks again. Yes I've been able to run pdflatex from the command line using the output format option to create a dvi file instead of pdf. Then I ran dvipng (included in the TexLive distribution) also from the command line to convert the dvi file into png. This all seems to be working very well.


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 9 guests