早知道有latex这么优秀的排版软件,毕业设计时果断会用的阿 想当初用word 排了几天版的人伤不起阿 大学杂这么优秀的工具都不过我们介绍呢!!

后来才知道一些大学早就有自己的latex模板了。。。再一次鄙视windows。。哈哈
回到主题。。
后来编译latex文件时觉得很麻烦 于是就打算用bash shell 写一个脚本一次搞定,自动编译成pdf文件,最后删除除源文件和pdf以外的其他文件(可自行修改)。。。
没有很高技术含量,就像练练bash shell,脚本如下,望老鸟指正。。。
代码: 全选
#!/bin/bash
# Program:
# name: t2p (just tex to pdf)
# Using latex command once or more if necessary to make certain.tex to
# certain.dvi .Then use dvipdfmx to transform certain.dvi to certain.pdf,at
# last delet the uesless file ex> *.aux *.log *.dvi or *.doc
# History:
# 2012/01/15 adfrog First release
# 2012/01/15 adfrog Second release
# change: use the awk language in the function nahz to be more exact
# 2012/02/04 adfrog Third release
# change: add function mte to make script concise
# 显示用法
function usage() {
echo -e "Usage:\n t2p [n] {filename.tex}"
echo "n==>指定编译次数 默认为一次"
}
# 获取名称和后缀
function nahz() {
na=`ls $file | awk 'BEGIN {FS="."} {printf $1}'`
hz=`ls $file | awk 'BEGIN {FS="."} {printf $2}'`
}
# 编译指定次数
function make() {
for (( i=1;i<=$1;i++ ))
do
latex $file
done
}
# 转化为pdf文件,并删除多余文件
function transclean() {
dvipdfmx $na.dvi
ls $na.* |grep -v "$file"|grep -v "pdf$"|xargs rm -r
}
# 处理文件的完整功能
function mte() { # mte just mean make then transclean and evince
make $num
transclean
evince $na.pdf
}
# 主程序
num=1
case $# in
"1")
file=$1
nahz
if [ "$?" == 0 ] && [ "$hz" == "tex" ];then
mte
exit 0
else
usage
exit 1
fi
;;
"2")
file=$2
nahz && echo $1|grep "^[0-9]*$" && [ "$hz" == "tex" ]
if [ "$?" == 0 ];then
num=$1
mte
exit 0
else
usage
exit 1
fi
;;
*)
usage
exit 1
;;
esac