Skip to content

Instantly share code, notes, and snippets.

@FromAtom
Created January 9, 2015 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FromAtom/895082ce7a4d1229be86 to your computer and use it in GitHub Desktop.
Save FromAtom/895082ce7a4d1229be86 to your computer and use it in GitHub Desktop.
LaTeXの自動ビルド用のOMakefile
###############################################################################
# w32texによるLaTeXファイルのビルドルール
# 次のようなディレクトリ構成を仮定している
# root
# ├ OMakeroot
# ├ OMakefile このファイル
# ├ document.tex TeXファイル (文字コードはUTF-8)
# ├ refs.bib bibファイル (文字コードはUTF-8)
# ├ hogehoge/ サブディレクトリ (名前は任意)
# │ ├ sub1.tex サブディレクトリにあるTeXファイルもコンパイルされる
# │ ├ sub2.tex 上に同じ
# └ images/ 画像はimagesディレクトリの下に置く
# ├ fig01.png png対応
# ├ fig02.jpg jpg対応 (拡張子は必ずjpgにすること)
# ├ fig03.pdf pdf対応
# └ fig04.eps eps対応
###############################################################################
# 生成するPDFの名前 (拡張子は不要)
TARGET = sample
# 画像ファイルを置くディレクトリ
IMAGE_DIR = images
# LaTeXコマンド
LATEX = platex
# TeTeX v.2にある発展的なLaTeXオプションを有効にするかどうか
TETEX2_ENABLED = false
# LaTeXに渡す引数
LATEXFLAGS = -interaction=nonstopmode --kanji=utf8
# BibTeXコマンド
BIBTEX = pbibtex --kanji=utf8
# .dviから.pdfへのコンバータ
DVIPDFM = dvipdfmx
# dvipdfmに渡す引数
DVIPDFMFLAGS = -p a4
# Bounding Box生成コマンド
EBB = extractbb
# グロブ展開に失敗したときに空の文字列を返すようにする
GLOB_OPTIONS = i
# Bounding Boxの生成ルール
.SUBDIRS: $(IMAGE_DIR)
%.xbb: %.png
$(EBB) $<
%.xbb: %.jpg
$(EBB) $<
%.xbb: %.pdf
$(EBB) $<
TEX_FILES = $(glob *.tex */*.tex)
BIB_FILES = $(glob *.bib)
EPS_IMAGE_FILES = $(glob $(IMAGE_DIR)/*.eps)
OTHER_IMAGE_FILES = $(glob $(IMAGE_DIR)/*.png $(IMAGE_DIR)/*.jpg $(IMAGE_DIR)/*.pdf)
IMAGE_FILES = $(EPS_IMAGE_FILES) $(OTHER_IMAGE_FILES)
XBB_FILES = $(addsuffix .xbb, $(removesuffix $(OTHER_IMAGE_FILES)))
# コンパイルに必要なファイル
TEXDEPS[] = $(TEX_FILES) $(BIB_FILES) $(IMAGE_FILES) $(XBB_FILES)
LaTeXDocument($(TARGET), $(TARGET))
.DEFAULT: $(TARGET).pdf $(TARGET).dvi
.PHONY: clean
clean:
rm $(glob *.toc *.log *.pdf *.dvi *.fls *.aux *.maf *.mtc *.bbl *.blg) $(XBB_FILES)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment