|

楼主 |
发表于 2003-10-5 02:56:25
|
显示全部楼层
居然贴子有修改期限……
这里只好再发,因为这个脚本功能比较单独,所以以后的更新就不再加贴了。欲获得最新版可以到水木清华的TeX版或是到我的ftp的personalWorks/alphatan/latex2pdf/下载(可能经常上不了……)。
0.55
修改了dvi函数,使其可以处理cross-reference。
一如既往地欢迎任何意见。
- #!/bin/bash
- #
- # "latex2pdf.sh" is a script written in bash to make processing latex
- # file easier.
- # Copyright (C) 2003 alphatan<alphatan@263.net> version 0.55
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 2 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #
- target=${1%.tex}
- action=$2
- declare -f dvi errorMsg ldvi lpdf lpdfmx lps lview pdf pdfmx ps view
- function errorMsg()
- {
- echo -e " Usage: ${0##*/} <filename> [action] " >&2
- echo -e " <filename> : the tex file with '.tex' extension. "
- echo -e " This could not be ignored."
- echo -e " [action] : the 'action' you wish to operate on the '.tex' file"
- echo -e " dvi : process to 'dvi' output"
- echo -e " ps : process to 'ps' output"
- echo -e " pdf : process to 'pdf' output with 'dvipdf' command "
- echo -e " pdfmx : process to 'pdf' output with 'dvipdfmx' command "
- echo -e " view : view the '<filename>.pdf' with 'acroread' \n"
- echo -e " The action type above could put an 'l' precede it. eg. 'ldvi' "
- echo -e " it will call the corresponding process and do a cleaning course by "
- echo -e " the end. "
- echo -e " If the 'action' is ignored, it is refer to 'lview', it would "
- echo -e " cause 'lpdfmx' and 'cleaning course', and view the '.pdf' output "
- echo -e " with 'acroread'"
- }
- if [ ! -e ${target}.tex ]; then
- echo -e "ERROR!!: ${target}.tex does not exist! " >&2
- errorMsg
- exit 1
- fi
- function dvi()
- {
- if latex ${target}.tex ; then
- if [ -e ${target}.idx ] ; then
- if makeindex ${target}.idx ; then
- if latex ${target}.tex ; then
- return 0;
- else return 1
- fi
- else return 1
- fi
- elif grep -in 'LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.' ${target}.log ; then
- if latex ${target}.tex ; then
- return 0
- fi
- else return 1
- fi
- }
- function ps()
- {
- if dvi ; then
- if dvips ${target}.dvi ; then
- return 0;
- else return 1
- fi
- else return 1
- fi
- }
- function pdf()
- {
- if dvi ; then
- if dvipdf ${target}.dvi ; then
- return 0;
- else return 1
- fi
- else return 1
- fi
- }
- function pdfmx()
- {
- if dvi ; then
- if dvipdfmx ${target}.dvi ; then
- return 0;
- else return 1
- fi
- else return 1
- fi
- }
- function view()
- {
- if [ -e ${target}.pdf ] ; then
- acroread ${target}.pdf
- else return 1
- fi
- }
- function cleanFiles()
- {
- echo "Cleaning process caught ... "
- unset i;
- for i in aux dvi idx ilg ind lof log lot pdf ps ; do
- if [ ! $i = $1 ]; then
- if [ -e ${target}.$i ]; then
- rm -f ${target}.$i
- fi
- fi
- done
- unset i;
- }
- function ldvi()
- {
- if dvi ; then
- cleanFiles dvi
- else return 1
- fi
- }
- function lps()
- {
- if ps ; then
- cleanFiles ps
- else return 1
- fi
- }
- function lpdf()
- {
- if pdf ; then
- cleanFiles pdf
- else return 1
- fi
- }
- function lpdfmx()
- {
- if pdfmx ; then
- cleanFiles pdf
- else return 1
- fi
- }
- function lview()
- {
- if lpdfmx ; then
- if acroread ${target}.pdf ; then
- return 0
- else return 1
- fi
- else return 1
- fi
- }
- case $action in
- dvi ) eval $action ;;
- ps ) eval $action ;;
- pdf ) eval $action ;;
- pdfmx ) eval $action ;;
- view ) eval $action ;;
- ldvi ) eval $action ;;
- lps ) eval $action ;;
- lpdfmx ) eval $action ;;
- lview ) eval $action ;;
- '' ) eval lpdfmx ;;
- * ) echo -e "Error Action type! " >&2
- errorMsg
- exit 1 ;;
- esac
复制代码
另外,对于本论坛的版面设置提点意见:
希望在“回复”的时候,不要把“清空内容”的按钮放在右下,我已经很多次把东西写完了却按了这东西,欲哭无泪,建议把它放到“标题”行的最后一列。 |
|