Math & ScienceTerminal commands on MacOS to access Latex

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

Terminal commands on MacOS to access Latex

Post by bob000 »

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.)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Terminal commands on MacOS to access Latex

Post by Johannes_B »

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

Terminal commands on MacOS to access Latex

Post by bob000 »

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: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Terminal commands on MacOS to access Latex

Post by Johannes_B »

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

Terminal commands on MacOS to access Latex

Post by bob000 »

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.
Post Reply