summarylogtreecommitdiffstats
path: root/tex2gr
blob: 21574a470ab4b4df573d278ed8b739ecf88f6cfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
TMPDIR=/tmp
DVI2GR=dvi2gr
# Not sure where this is supposed to be relative to
FPATH="fonts/type1"
LATEX=latex

input=$1

if [ $input == "--help" ]; then
	echo "Usage: tex2gr <latex_snippet>"
	echo "Snippet should begin and end with '$' if it contains math"
	exit 0
fi

bname=$TMPDIR/dvi2gr$$
itex=$bname.tex
idvi=$bname.dvi
iaux=$bname.aux
ilog=$bname.log

istr=`sed 's/\\\\/\\\\\\\\/g' $input`

cat << EOPRE > $itex
\documentclass[10pt]{article}
\pagestyle{empty}
\begin{document}
EOPRE

cat $input >> $itex

cat << EOPOST >> $itex
\end{document}
EOPOST

$LATEX --output-directory=$TMPDIR/ $itex > /dev/null
ostr=`$DVI2GR $FPATH $idvi`

echo "$ostr"

rm -f $itex $idvi $iaux $ilog