うさぎのしっぽ

プログラミングとか。備忘録として使ってるブログです。あとは趣味少し。 間違いなどありましたらご指摘ください(・3・)

.texからpdfを作成するシェルスクリプト

毎回コマンド打つのだるかったから自作した.

フォントの埋め込みはコメントで切り替える.

platexでエラーが出ても止まらないことに注意

 

フォント埋め込み状態の確認方法:

http://www.matsucollo.co.jp/homepage/comic/datamake/pdf_font.html

 

#!/bin/sh
#
# [last updated : July 28, 2014]
#
#
# texファイルからpdfを作成するプログラム
# -フォントの埋め込みはコメントで切り替え
#
#【ソースファイルの指定に.texは不要】
# study.tex → study.pdf を行う場合は study と指定する
#
# 引数の数によって参考文献ファイルの有無を変更する
#
#
#
# 実行時に指定された引数の数で分岐
#
# 0 - 引数に何を指定すればいいか表示
# 1 - 参考文献ファイル無し
# 2 - 参考文献ファイル有り


# if ( $# == 0 ) then ...
if [ $# -eq 0 ]; then
echo "this program needs one or two argments" 1>&2
echo " source [sansyou]" 1>&2
exit 1

# elsif ( $# == 1 ) then ...
elif [ $# -eq 1 ] ; then

platex ${1}.tex # -文章をコンパイルします.
platex ${1}.tex # -(相互参照を使っているときのため)もう一度コンパイルします.

#dvipdfmx -f ipa.map ${1}.dvi # -dviファイルをpdfファイルに変換します.フォント埋め込みアリ
dvipdfmx ${1}.dvi # -dviファイルをpdfファイルに変換します.フォント埋め込みなし


# elsif ( $# == 2 ) then ...
elif [ $# -eq 2 ] ; then

platex ${1}.tex # -文章をコンパイルします.
platex ${1}.tex # -(相互参照を使っているときのため)もう一度コンパイルします.
jbibtex ${1} # -参考文献ファイルとtexファイルとの対応付けを行います.(拡張子は記述しません.)
platex ${1}.tex # -もう一度コンパイルします.

#dvipdfmx -f ipa.map ${1}.dvi # -dviファイルをpdfファイルに変換します.フォント埋め込みアリ
dvipdfmx ${1}.dvi # -dviファイルをpdfファイルに変換します.フォント埋め込みなし


else
echo "too many argments" 1>&2
exit 1
fi


echo "all done"

 

 

 バージョン情報

user%platex -v
pTeX 3.141592-p3.1.9 (EUC) (Web2C 7.5.4)
kpathsea version 3.5.4
Copyright (C) 1999 D.E. Knuth.
Kpathsea is copyright (C) 1999 Free Software Foundation, Inc.
There is NO warranty. Redistribution of this software is
covered by the terms of both the pTeX copyright and
the GNU General Public License.
For more information about these matters, see the files
named COPYING and the pTeX source.
Primary author of TeX: D.E. Knuth.
Kpathsea written by Karl Berry and others.