]>
git.rmz.io Git - dotfiles.git/blob - bin/tex2im
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] inputfile
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[dvips]{graphicx}
142 # Do we have a file containing extra files to include into the header?
145 if [ -f $extra_header ]; then
151 if [ $noformula -eq 1 ]; then
170 if [ -e "$infile" ]; then
171 cat $infile >> $tmpdir/out.tex
173 echo $infile >> $tmpdir/out.tex
176 if [ $noformula -eq 1 ]; then
192 for f in $homedir/*.eps; do
193 test -f ${f##*/} || ln -s $f . # multi-processing!
195 latex -interaction=batchmode out.tex > /dev/null
197 dvips -o $tmpdir/out.eps -E $tmpdir/out.dvi 2> /dev/null
200 # Transparent background
203 if [ $trans -eq 1 ]; then
204 if [ $aa -eq 1 ]; then
205 convert +adjoin -antialias -transparent $color1 -density $resolution $tmpdir/out.eps $tmpdir/out.$format
207 convert +adjoin +antialias -transparent $color1 -density $resolution $tmpdir/out.eps $tmpdir/out.$format
210 if [ $aa -eq 1 ]; then
211 convert +adjoin -antialias -density $resolution $tmpdir/out.eps $tmpdir/out.$format
213 convert +adjoin +antialias -density $resolution $tmpdir/out.eps $tmpdir/out.$format
218 if [ -e $tmpdir/out.$format ]; then
219 mv $tmpdir/out.$format $outfile
221 mv $tmpdir/out.$format.0 $outfile