PukiWikiでTeXを利用するためのプラグインです。
実装を見ていただければ分かるとおり、単にplatexとdvipngを呼び出しているに過ぎません。 また、TeXドキュメントも私の好みに設定していますので、ご自分で好きなフォームに改変してご利用ください。
特徴
目次
起動方法
終了方法
操作方法
PukiWikiの編集で、次の書式に従って式を記述します。 編集後に式が画像ファイル(png形式)に変換されます。
(書式1)行頭で使用します。表でも使用できます。
#math2()
(書式2)行中で使用できます。
&math2{};
注意事項
<?php // Copyright(C) 2007 fem. All rights reserved. define( "IMG_DIR", "./mathimg/" ); define( "IMG_EXT", ".png" ); function make_math2_img( $aryargs ) { $math = join( $aryargs,"," ); //remove extra comma at the end. $math = rtrim( $math, "," ); $imgfile = md5( $math ).IMG_EXT; if ( !file_exists( IMG_DIR.$imgfile ) ) { $tmpfile = IMG_DIR."tmp.tex"; $tmp = fopen( $tmpfile, "w" ); fputs( $tmp, '\documentclass[12pt]{jarticle}'."\n" ); fputs( $tmp, '\usepackage{amsmath,amssymb,bm}'."\n" ); fputs( $tmp, '\pagestyle{empty}'."\n" ); fputs( $tmp, '\begin{document}'."\n" ); fputs( $tmp, '\thispagestyle{empty}'."\n" ); fputs( $tmp, '\large\['.$math.'\]'."\n" ); fputs( $tmp, '\end{document}'."\n" ); fclose( $tmp ); $oldDir = getcwd(); chdir( IMG_DIR ); exec( "platex -halt-on-error tmp.tex" ); exec( "dvipng -bg 'rgb 1.0 1.0 0.4' -bd 1000 -T tight --gamma 1.1 -o tmp.png tmp.dvi" ); exec( "move tmp.png ".$imgfile ); chdir( $oldDir ); } return "<IMG SRC=".IMG_DIR.$imgfile.">"; } function plugin_math2_convert() { $aryargs = func_get_args(); return make_math2_img( $aryargs ); } function plugin_math2_inline() { $aryargs = func_get_args(); return make_math2_img( $aryargs ); } ?>
プラットフォーム依存関係
PukiWiki | 1.4.7 |
pLaTeX | |
dvipng |
本体
math2.inc.phpをpluginフォルダに置いてください。格納後、すぐに利用できます。
拡張オプション
math2.inc.phpをpluginフォルダから削除します。
スパム防止のため、編集には認証を必要としています。guest/guestで。
カテゴリ:フリーウェア