2 #############################################################
3 # TEX2IM: Converts LaTeX formulas to pixel graphics which #
4 # can be easily included in Text-Processors like #
7 # Required software: latex, convert (image magic) #
8 # to get color, the latex color package is required #
9 #############################################################
10 # Version 1.8 (http://www.nought.de/tex2im.html) #
11 # published under the GNU public licence (GPL) #
12 # (c) 14. May 2004 by Andreas Reigber #
13 # Email: anderl@nought.de #
14 #############################################################
27 extra_header
="$HOME/.tex2im_header"
29 if [ -f ~
/.tex2imrc
]; then
36 echo "Usage: `basename $0` [options] file.tex, for help give option -h" 1>&2
40 while getopts hanzb
:t
:f
:o
:r
:vx
: Optionen
; do
42 h
) echo "tex2im [options] latex_expression
44 The content of input file should be _plain_ latex mathmode code!
45 Alternatively, a string containing the latex code can be specified.
50 -a change status of antialiasing
51 default is on for normal mode and
52 off for transparent mode
53 -o file specifies output filename,
54 default is inputfile with new extension
55 -f expr specifies output format,
56 possible examples: gif, jpg, tif......
57 all formates supported by 'convert' should work,
59 -r expr specifies desired resolution in dpi,
60 possible examples: 100x100, 300x300, 200x150,
62 -b expr specifies the background color
64 -t expr specifies the text color
66 -n no-formula mode (do not wrap in eqnarray* environment)
68 -z transparent background
70 -x file file containing extra header lines.
71 default: ~/.tex2im_header"
73 v
) echo "TEX2IM Version 1.8"
75 r
) resolution
=$OPTARG;;
79 a
) if [ $aa -eq 0 ]; then
88 x
) extra_header
=$OPTARG;;
93 # Generate temporary directory
96 if test -n "`type -p mktemp`" ; then
97 tmpdir
="`mktemp /tmp/tex2imXXXXXX`"
102 if [ -e $tmpdir ] ; then
103 echo "$0: Temporary directory $tmpdir already exists." 1>&2
108 homedir
="`pwd`" ||
exit 1
111 # Names for input and output files
114 while [ $OPTIND -le $# ]
117 eval infile
=\$
${OPTIND}
119 if [ -z $outfile ]; then
120 if [ -e "$infile" ]; then
121 base
=`basename ${infile} .tex` ;
122 outfile
=${base}.
$format
134 \documentclass[12pt]{article}
136 \usepackage{amsmath,latexsym,amsfonts,amssymb,ulem}
137 \usepackage[dvips]{graphicx}
143 # Do we have a file containing extra files to include into the header?
146 if [ -f $extra_header ]; then
152 if [ $noformula -eq 1 ]; then
171 # Kopete does not need to parse the content of a file.
172 #if [ -e "$infile" ]; then
173 # cat $infile >> $tmpdir/out.tex
175 echo "$infile" >> $tmpdir/out.tex
178 if [ $noformula -eq 1 ]; then
194 for f
in $homedir/*.eps
; do
195 test -f ${f##*/} ||
ln -s $f .
# multi-processing!
197 latex
-interaction=batchmode out.tex
> /dev
/null
199 dvips
-o $tmpdir/out.eps
-E $tmpdir/out.dvi
2> /dev
/null
202 # Transparent background
205 if [ $trans -eq 1 ]; then
206 if [ $aa -eq 1 ]; then
207 convert
+adjoin
-antialias -transparent $color1 -density $resolution $tmpdir/out.eps
$tmpdir/out.
$format
209 convert
+adjoin
+antialias
-transparent $color1 -density $resolution $tmpdir/out.eps
$tmpdir/out.
$format
212 if [ $aa -eq 1 ]; then
213 convert
+adjoin
-antialias -density $resolution $tmpdir/out.eps
$tmpdir/out.
$format
215 convert
+adjoin
+antialias
-density $resolution $tmpdir/out.eps
$tmpdir/out.
$format
220 if [ -e $tmpdir/out.
$format ]; then
221 mv $tmpdir/out.
$format $outfile
223 mv $tmpdir/out.
$format.0 $outfile