Skip to content

Instantly share code, notes, and snippets.

@tkf
Created August 23, 2009 07:31
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 tkf/173187 to your computer and use it in GitHub Desktop.
Save tkf/173187 to your computer and use it in GitHub Desktop.
Makefile for rst2latexmath
TOOLSROOT=../tools
rst2latex=python ${TOOLSROOT}/rst2latex.py
rst2latexmath=python ${TOOLSROOT}/rst2latexmath.py
rst2mathml=python ${TOOLSROOT}/rst2mathml.py
###
.PHONY: allpdf
allpdf: $(shell find . -name "*.txt" \
| sed -e 's/txt/pdf/' -e 's/.*/_build\/latexmath\/&/')
_build/latexmath/%.pdf: _build/latexmath/%.dvi
cd `dirname $<`; dvipdfmx `basename $<`
_build/latexmath/%.dvi: _build/latexmath/%.tex
cd `dirname $<`; platex `basename $<`; platex `basename $<`
_build/latexmath/%.tex: %.txt _build/latexmath
${rst2latexmath} \
--stylesheet=amsmath.sty,amsfonts.sty,amssymb.sty \
--output-encoding=EUC-JP --language=ja --documentclass=jarticle \
$< | sed \
-e 's/\\usepackage\[eucjp\]{inputenc}/%& %% for platex/' \
-e 's/\\usepackage{babel}/%& %% for platex/' \
-e 's/\(\\usepackage\[\)\(.*\]{hyperref}\)/\1dvipdfmx,\2/' \
-e 's/\\usepackage\[.*\]{hyperref}/& \\AtBeginDvi{\\special{pdf:tounicode EUC-UCS2}}/' \
> $@
###
_build/latexmath: _build
mkdir $@
_build/mathml: _build
mkdir $@
_build:
mkdir _build
.PHONY: clean
clean:
rm -rf _build/*
# http://docutils.sourceforge.net/sandbox/jensj/latex_math/ を使う方法
# allpdf あたり
# + reStructured Text tips and tricks - http://www.programmerq.net/rsttricks.html
# rst -> tex の後処理の参考:
# + ps2pdf/dvipdfmx で日本語 PDF を作る > 日本語のしおり
# - http://www.nn.iij4u.or.jp/~tutimura/tex/dvipdfm.html#bookmark
# これの,「dvipdfmx の場合」を参考にした
# あとは,
# + LaTeXでhyperrefを使う - 外圏Wiki
# - http://windom.phys.hirosaki-u.ac.jp/fswiki/wiki.cgi?page=LaTeX%A4%C7hyperref%A4%F2%BB%C8%A4%A6
# 他に試した方法: platex -> dvips -> convert-euc.txt -> ps2pdf
# + hyperrefと日本語
# - http://www.rmatsumoto.org/tex-ps-pdf/hyperref.ja.html
# + new rpms for my VineSeed - がべこれログ - Garbage Collection Log
# - http://d.hatena.ne.jp/munepi/20090514/1242311027
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment