How to make a rich png image from a Latex Math Equation
1,306
Here is my script, maybe it will be useful for you:
#!/bin/sh
prefix="tmp_$$"
if [ "$1" = "" ]; then
echo -e "\nUsage: $(basename $0) \"latex string\" [output filename]\n"
exit
fi
[ "$2" != "" ] && output="$2" || output=$(date +%y.%m.%d_%H:%M:%S.png)
tex="$prefix.tex"
cat > $tex << EOF
\documentclass[12pt]{minimal}
\usepackage[koi8-r]{inputenc}
\usepackage[english,russian]{babel}
\usepackage[intlimits]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{wasysym}
\pagestyle{empty}
\parindent=0pt
\setbox0=\hbox{
EOF
echo $1 >> $tex
cat >> $tex << EOF
}
\textheight=\ht0
\textwidth=\wd0
\oddsidemargin=-1cm
\topmargin=-1.5cm
\advance\textheight by 1cm
\advance\textwidth by 1cm
\begin{document}
\vbox{\vss\hbox{\hss\copy0\hss}\vss}
\end{document}
EOF
latex $tex
dvipng -D 600 $prefix.dvi -o $output
rm -f $prefix*
It generates png files from command line.
Related videos on Youtube
Author by
dustin
Updated on August 01, 2022Comments
-
dustin over 1 year
I have a
LaTeX
math equation that I have been trying to convert it into a rich.png
image by compiling the.tex
file into.dvi
and then from.dvi
to.png
. But I noticed that the Image is small and the background of the image is dark. Below is my code:\documentclass[30pt]{article} \DeclareMathSizes{30}{30}{30}{30} \usepackage{amsmath} \begin{document} \pagenumbering{gobble} \begin{displaymath} \int\frac{d\theta}{1+\theta^2} = \tan^{-1}\theta+ C \end{displaymath} \end{document}
-
Peter Grill over 10 yearsWelcome to TeX.SE. Does How to export a equation as a image without background? answer your question? If so we can close this question as a duplicate.
-