latex2eps.sh出现的错误,请会脚本的帮忙看看

OOo,TeX,KO,ABI,GIMP,Picasa,ProE,QCAD,Inkscape,Kicad,Eagle
回复
yuanwucai
帖子: 12
注册时间: 2009-07-02 21:30

latex2eps.sh出现的错误,请会脚本的帮忙看看

#1

帖子 yuanwucai » 2009-09-30 17:22

我从网上下了一个脚本文件"latex2eps.sh",该脚本可以把latex公式转换成.eps图片,但是我用的时候出现了错误。

具体操作如下:

1, 新建一个文本文件,输入latex公式,保存为"file1":

代码: 全选

$$\mbox{Power} = \frac{1}{2} \rho A v^3$$
2, 在终端中执行:

代码: 全选

./latex2eps.sh Wind0 < file1
按照说明文档中的说法,这时候应该能得到"Wind0.eps"图片,但是我却出错:

代码: 全选

dvips: ! DVI file can't be opened.
检查发现,生成了一个"Wind0.tex"文件,如下图:
&quot;Wind0.tex&quot;文件
"Wind0.tex"文件
其中第3,4行出错了,其对应的"latex2eps.sh"中的语句为:

代码: 全选

echo '\begin{document}' >> $texnew
echo '\thispagestyle{empty}' >> $texnew
很明显,是把'\b'和'\t'识别错了,怎么办?
谢谢!

附上"latex2eps.sh"的代码:

代码: 全选

#! /bin/sh
#
# latex2eps.sh - translates latex math formula to EPS
#
# Expected usage:
#	%filter "latex2eps.sh eqn"
#   \begin{displaymath}
#	\frac{1}{x+y}
#   \end{displaymath}
#	%endfilter
#	%image "eqn.eps" 250x200
#
# additional style can be used with option -sty, eg.
#   latex2eps -sty pslatex -sty color eqn
#
# History:
#   18.03.2003  first creation
#   06.03.2003  support for subdirs added
#

#parse command line options
STYLES=""
while [ $# -gt 0 ]
do
	case "$1" in
	# additional styles
	-sty) STYLES="$STYLES $2"; shift;;
	# temporary filename (without .eps suffix)
	*)    tmp=$1;;
	esac
	shift
done

# in case a different directory is given:
datadir="`dirname $tmp`"
if [ ! -z "$datadir" ]
then
	tmp="`basename $tmp`"
	cd "$datadir"
fi

# target TeX file and temporary new file
tex=$tmp.tex
texnew=$tmp.tex.new

# write new TeX file
echo '\documentclass[fleqn]{article}' > $texnew
echo '\usepackage[latin1]{inputenc}' >> $texnew
for sty in $STYLES
do
	echo "\usepackage{$sty}" >> $texnew
done
echo '\begin{document}' >> $texnew
echo '\thispagestyle{empty}' >> $texnew
echo '\mathindent0cm' >> $texnew
echo '\parindent0cm' >> $texnew
cat >> $texnew
echo '\end{document}' >> $texnew

# exit when no change
test -e $tmp.eps && test -e $tex && diff $tex $texnew >/dev/null 2>&1 && {
	/bin/rm -f $texnew
	exit 0; }

# otherwise process TeX file
mv $texnew $tex
latex $tex > /dev/null 2> /dev/null
dvips -q -E $tmp.dvi -o $tmp.eps
/bin/rm -f $tmp.log $tmp.dvi $tmp.aux
"latex2eps.sh"的使用说明:
Demonstration_of_latex2eps.pdf
"latex2eps.sh"的使用说明
(47.93 KiB) 已下载 12 次
yuanwucai
帖子: 12
注册时间: 2009-07-02 21:30

Re: latex2eps.sh出现的错误,请会脚本的帮忙看看

#3

帖子 yuanwucai » 2009-10-03 11:57

怎么没人回呢…… :em20
回复