TUG 2013 㧠PythonTeX ã«ã¤ãã¦ã®çºè¡¨ããã£ã¦å°ã話é¡ã«ãªã£ã¦ãããããã
PythonTeX ã¨ããã®ã¯ã端çã«ããã¨ããLaTeX ææ¸ä¸ã§ Ruby ã®ããã°ã©ã ãå®è¡ããæ©è½ããæä¾ããããã±ã¼ã¸ã§ãããããªãã¡ãPerlTeX ã® Ruby çãã«ç¸å½ããããªã®ã§ããã¡ãã£ã¨è¤é㪠LaTeX å½ä»¤ãå®è£ ãããããTeX ã expl3 ã Lua ã Perl ã LISP on TeX ãããªã㦠Ruby ã使ãããï¼ãã¨ãã人ã¯æ¯éã¨ã試ãã¹ãã§ãããã
ããã±ã¼ã¸èªä½ã¯æè¿ã® TeX Live 2013 ã§ããã°æ¢ã«ã¤ã³ã¹ãã¼ã«ããã¦ããããã ããLuaTeX ã®ãããªãè¨èªå¦çç³»ãçµã¿è¾¼ãã TeX ã¨ã³ã¸ã³ãã§ã¯ãªããPerlTeX ã®ããã«ãTeX ã¨è¨èªå¦çç³»ãé£æºãããå½¢ã§åä½ããã®ã§ãå¥é Ruby ã®ã¤ã³ã¿ããªã¿ãã¤ã³ã¹ãã¼ã«ããã¦ããå¿ è¦ãããããã¨ãã©ããã Python *1ãå¿ è¦ãããã
ã¨ããããã§ãæ©é \NabeAzz
å½ä»¤ã Ruby ã§å®è£
ãã¦ã¿ãã
% pLaTeX ææ¸; æåã³ã¼ãã¯ä¸å¿UTF-8 \documentclass[a4paper]{jsarticle} \usepackage[usefamily=ruby]{pythontex} \usepackage{type1cm} \newcommand*{\textFunny}[1]{% {\usefont{OT1}{cmfr}{m}{it}\LARGE #1}% } \newcommand{\NabeAzz}[1]{% \rubyc{nabeazz(#1)}% } \begin{rubycode} def nabeazz(n) 1.upto(n).each do |i| puts((i % 3 == 0 || i.to_s =~ /3/) ? "\\textFunny{#{i}}" : i) end end \end{rubycode} \begin{document} 3ã®åæ°ã¨3ãä»ãæ°åã®ã¨ãã ãFunnyã«ãªãã¾ãã \begin{quote} \NabeAzz{40} \end{quote} \end{document}
LuaTeX ã®ãããªã¨ã³ã¸ã³æ¡å¼µã§ã¯ãªãã®ã§ãTeX ã¨ã³ã¸ã³ã¯å¥½ããªãã®ãé¸ã¹ãããªã®ã§ããã§ã¯æ¢ã㦠pLaTeX ã使ã£ãããã¬ã¢ã³ãã«ã«ããã¦
\usepackage[usefamily=ruby]{pythontex}
ãå®è¡ãã¦ããã±ã¼ã¸ãèªã¿è¾¼ãã¨ãRuby ã使ç¨ããããã®ä»¥ä¸ã®æ©è½ãæä¾ãããã
\rubyc{}
ï¼ Ruby ã®ã³ã¼ããå®è¡ãããå®è¡ä¸ã«æ¨æºåºåã«åºåããæåå㯠TeX å´ã¸ã®å ¥åã¨ãªããä¾ãã°ã\rubyc{puts(40%3)}
ã¯1
ã¨æ¸ããã®ã¨åçã«ãªãã((LuaTeX ã®tex.print()
ã¨åæ§ã®åä½ã¨ãªãããã ããå®éã«ãå®è¡ãèµ·ããé åºã¯ LuaTeX ã®å ´åã¨ã¯ç°ãªãããæããã¯è«ççã«ãç価ã§ã¯ãªãã¯ãã))ã½ã¼ã¹ã³ã¼ãä¸ã® LaTeX ã®ç¹æ®æå㯠verbatim ã«æ±ãããã®ãæ¬æ¥ã®åä½ã ããæ¨æºã®\verb
ç³»ã®å½ä»¤ã¨åæ§ãä»ã®å½ä»¤ã®å¼æ°ã®ä¸ã§ã¯ verbatim æ§ã失ããããï¼ã ãããä¸ã®ä¾ã®\NabeAzz
ã®å®ç¾©ã§ã¯#1
ãã¡ããã¨å½ä»¤å¼æ°ã®æå³ã«ãªãã((ããªãå¾®å¦ãªåä½ã§ããããããã¥ã¢ã«ã«ããã¦åæ§ã®ä¾ãæãããã¦ããã®ã§ããããæ£å¼ãªä»æ§ã¨èãã¦ããã ããããªãã\verb
ã¨åæ§ã®\rubyc|40%3|
ã®ãããªæ¸ãæ¹ãã§ãããå¼æ°ã{ }
ã«å ¥ããå ´åã¯å½ç¶{ }
ã«ã¤ãã¦åè¡¡ã§ããå¿ è¦ãããã))ï¼\ruby{}
ï¼ ãã®å ´åãã½ã¼ã¹ã³ã¼ãã¯åä¸ã®ï¼Ruby ã®ï¼å¼ã§ãªããã°ãªããããã®å¼ã®å¤ï¼ã®æåååï¼ã TeX å´ã¸ã®å ¥åã¨ãªããä¾ãã°ã\ruby{40%3}
ã¯1
ã¨åçã«ãªããå¼æ°ã® verbatim æ§ã¯\rubyc
å½ä»¤ã¨åãã\begin{rubycode}\end{rubycode}
ï¼\rubyc
ã®ç°å¢çãç°å¢ã®å 容ã¯ï¼å¼æ°å ã§ãªãéãï¼verbatim ã«æ±ãããã
ææ¸ã®ã³ã³ãã¤ã«ã®æé ã¯ä»¥ä¸ã®éãã§ããã((ãã¡ãã pTeX ã¨ã³ã¸ã³ã®æ¢å®ã®å
¥åæ¼¢åã³ã¼ãã UTF-8 ã§ããå ´å㯠-kanji=utf8
ã¯ä¸è¦ã))
platex -kanji=utf8 test-ruby pythontex test-ruby platex -kanji=utf8 test-ruby
ãã㧠test-ruby.dvi ãå¾ããããDVI ææ¸ãã PostScript ã PDF ã¸ã®å¤æã¯é常ã®ææ¸ã®å ´åã¨å¤ãããªãã((ãã欧æã® pdflatex ç¨ã®ææ¸ã§ããå ´åã¯ãæé ã® platex -kanji=utf8
ã pdflatex
ã§ç½®ãæãããä»ã®ã¨ã³ã¸ã³ã®å ´åãåãã))以ä¸ã®ãããªåºåãå¾ãããã
è£è¶³äºé ã
- ããã±ã¼ã¸ã®æ¢å®ã§ã¯ãææ¸ã®æåã³ã¼ã㯠UTF-8 ã§ãããã¨ãæ³å®ããã¦ããã
- LaTeX ã®ç¹æ®æåã®åé¡ãããã®ã§ãè¤é㪠Ruby ã³ã¼ãã¯é¢æ°ï¼ãã¯ã©ã¹ï¼ã«ã㦠rubycode ç°å¢ã®ä¸ã«ç½®ãããLaTeX ã³ã¼ãã¨æ··å¨ããç®æãã§ã¯
\rubyc
ã\ruby
å½ä»¤ã使ããã¨ããå½¢ãæ¸ããããã§ãããã - å®ã¯ Ruby å®è¡ã®å½ä»¤ã»ç°å¢ã¯ï¼ãã¬ã¢ã³ãã«ã§ãªãï¼ææ¸æ¬ä½ä¸ã§ã使ç¨å¯è½ã§ããããããç§ã¯æ¬ä½ä¸ã«ããã°ã©ã è¨èªï¼TeX ã ããã expl3 ã ããã Ruby ã ãããï¼ãæ¸ãã®ãæ¿ããå«ã£ã¦ããã®ã§ãä¸æ²ã®ä¾ã§ã¯ãLaTeX å½ä»¤ã Ruby ã§å®è£ ãããã¨ããå½¢ãã¨ã£ãã
ã¨ããããã§ãããããã®æ代ã¯ãLaTeX ã§å°ã è¤éãªå¦çãããå ´åã«ã¯ã
TeX ã§ã¯ãªã㦠Ruby ï¼ã¨ãï¼ã使ããã§ã¯ãªããï¼
*1:Python ã¯ã¹ã¯ãªããè¨èªã®ä¸ç¨®ã§ããããããå¤åãããã°ã©ã ãæ¸ãã®ã«ä½¿ãããã®ã ããã