{"id":12253,"date":"2023-11-30T00:11:42","date_gmt":"2023-11-30T00:11:42","guid":{"rendered":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=12253"},"modified":"2024-01-21T12:52:48","modified_gmt":"2024-01-21T12:52:48","slug":"%e6%95%b0%e5%bc%8f%e3%81%ae%e7%94%bb%e5%83%8f%e3%82%92%e4%bd%9c%e3%82%8b","status":"publish","type":"post","link":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=12253","title":{"rendered":"\u6570\u5f0f\u306e\u753b\u50cf\u3092\u4f5c\u308b"},"content":{"rendered":"<p>\u6570\u5f0f\u306e\u753b\u50cf\u3092\u305f\u304f\u3055\u3093\u4f5c\u308b\u6e96\u5099\u3067\u3059\u3002\u307e\u305a ubuntu22 \u306b\u3044\u304f\u3064\u304b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3002synaptic \u304b\u3089\u4e0b\u8a18\u3092\u5165\u308c\u308b\u3002<\/p>\n<ul>\n<li>nkf<\/li>\n<li>texlive-lang-cjk<\/li>\n<li>texlive-fonts-recommended<\/li>\n<li>texlive-fonts-extra<\/li>\n<li>xdvik-ja<\/li>\n<li>imagemagick<\/li>\n<\/ul>\n<p>imagemagick \u306f\u8a2d\u5b9a\u304c\u5fc5\u8981\u3002\/etc\/ImageMagick-6\/policy.xml \u3092\u7de8\u96c6\u3059\u308b\u3002\u4ee5\u524d\u306b<a href=\"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=7385\">\u8a18\u4e8b<\/a>\u3092\u66f8\u3044\u305f\u304c\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u306b\u3088\u3063\u3066\u8a18\u8ff0\u304c\u7570\u306a\u308b\u3088\u3046\u3060\u3002\u3053\u306e\u8a18\u8ff0\u5185\u5bb9\u306b\u306f\u81ea\u4fe1\u304c\u306a\u3044\u3002<\/p>\n<pre><code style=\"color: midnightblue; font-size: 12px; white-space: pre-wrap;\">  &lt;!-- disable ghostscript format types --&gt;\r\n  &lt;policy domain=\"coder\" rights=\"read|write\" pattern=\"PS\" \/&gt;\r\n  &lt;policy domain=\"coder\" rights=\"read|write\" pattern=\"PS2\" \/&gt;\r\n  &lt;policy domain=\"coder\" rights=\"read|write\" pattern=\"PS3\" \/&gt;\r\n  &lt;policy domain=\"coder\" rights=\"read|write\" pattern=\"EPS\" \/&gt;\r\n  &lt;policy domain=\"coder\" rights=\"read|write\" pattern=\"PDF\" \/&gt;\r\n  &lt;policy domain=\"coder\" rights=\"none\" pattern=\"XPS\" \/&gt;<\/code><\/pre>\n<p>\u3053\u306e\u4ed6\u3001php-mbstring \u3092\u5165\u308c\u308b\u3002<\/p>\n<p>\u4ee5\u524d\u66f8\u3044\u305f\u3001php \u3067 TeX \u306e\u30bd\u30fc\u30b9\u3092\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u306b\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3082\u306e\u3067\u3042\u308b\u3002<\/p>\n<pre><code style=\"color: midnightblue; font-size: 12px; white-space: pre-wrap;\">&lt;?php\r\n\r\n$stamp =  microtime();\r\nlist($msec, $sec) = explode(\" \", $stamp);\r\n\r\n$msec = $msec + 1;\r\n$msec = (string)$msec*1000000;\r\n$msec = substr($msec,1);\r\n$timestamp = $sec.$msec;\r\n$head = \"tmp\".$timestamp;\r\n$tmp = $head.\"_log.txt\";\r\n\r\n$logfile = fopen(\"$tmp\",\"w\");\r\n\r\n$tmp='\\frac{1}{\\sqrt{2}}';\r\n\r\necho \"$tmp \\n\";\r\n\r\nfputs($logfile,\"$tmp \\n\");\r\n\r\n$texword = $tmp;\r\n$tmp = $head.\".tex\";\r\n\r\n$texfile = fopen(\"$tmp\",\"w\");\r\n\r\n$word = mb_convert_encoding($texword, \"UTF-8\", \"auto\");\r\n\r\necho \"namae = $head, texword = $word \\n\";\r\n\r\n$tmp = &lt;&lt;&lt; end_of_quote\r\n\\\\documentclass{jarticle}\r\n\\\\special{papersize=73mm,40mm}\r\n\\\\setlength{\\\\hoffset}{-20.0mm}\r\n\\\\setlength{\\\\voffset}{-14.9mm}\r\n\\\\setlength{\\\\oddsidemargin}{0mm}\r\n\\\\setlength{\\\\topmargin}{0mm}\r\n\\\\setlength{\\\\headheight}{0mm}\r\n\\\\setlength{\\\\headsep}{0mm}\r\n\\\\setlength{\\\\textwidth}{72mm}\r\n\\\\setlength{\\\\textheight}{13mm}\r\n\\\\setlength{\\\\unitlength}{1mm}\r\n\\\\pagestyle{empty}\r\n\\\\begin{document}\r\n%\\\\makebox&#12434;&#20351;&#12358;&#12392;&#31665;&#12434;&#26360;&#12363;&#12394;&#12356;\r\n%\\\\framebox&#12434;&#20351;&#12358;&#12392;&#31665;&#12434;&#26360;&#12367;\r\n\\\\noindent\r\n\\\\makebox(71,13)[l]{{\\\\Huge \\\\quad \\$ \\\\displaystyle $word \\$ }}\r\n%makeswfp.php&#12392;&#30064;&#12394;&#12426;&#12289;&#19978;&#35352;tex&#12477;&#12540;&#12473;&#12434;\\$ \\$ &#12391;&#25375;&#12416;&#24517;&#35201;&#12364;&#12354;&#12427;&#12290;\r\n\\\\end{document}\r\n\r\nend_of_quote;\r\n\r\necho $tmp;\r\n\r\nfputs($logfile,$tmp);\r\nfputs($texfile,$tmp);\r\nfclose($texfile);\r\n\r\npassthru( \"nkf --overwrite -W .\/$head.tex\");\r\n\r\n$tmp = passthru( \"platex .\/$head.tex\");\r\npassthru( \"dvipdfmx -f .\/ipa.map .\/$head.dvi\");\r\n\r\npassthru( \"dvips -E -Ppdf .\/$head.dvi -o .\/$head.eps\");\r\npassthru( \"convert .\/$head.eps .\/$head.png\");\r\n\r\nfputs($logfile,\"$tmp \\n\");\r\nfclose($logfile);\r\n\r\nif (file_exists(\".\/$head.png\")) {\r\n&#9;passthru( \"rm $head.aux; rm $head.dvi; rm $head.log; rm $head.tex; rm $head\\_log.txt\");\r\n&#9;echo 'this$$'.$head.'$$that'.\"\\n\";\r\n} else {\r\n&#9;echo 'this$$error$$that'.\"\\n\";\r\n}\r\n?&gt;<\/code><\/pre>\n<p>ipa.map \u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u304c\u5fc5\u8981\u3067\u3042\u308b\u304c\u3001\u305d\u308c\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306a\u5185\u5bb9\u306e\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3067\u3042\u308b\u3002<\/p>\n<pre><code style=\"color: midnightblue; font-size: 12px; white-space: pre-wrap;\">rml   H ipam.ttf\r\ngbm   H ipag.ttf\r\nrmlv  V ipam.ttf\r\ngbmv  V ipag.ttf<\/code><\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3057\u305f\u3068\u3053\u308d\u3001\u6570\u5f0f\u306e\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u304c\u5f97\u3089\u308c\u305f\u3002\u3042\u3068\u306f\u3001Python \u306b\u66f8\u304d\u76f4\u3059\u3050\u3089\u3044\u304b\u3002<\/p>\n<p>Python \u306b\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre><code style=\"color: midnightblue; font-size: 12px; white-space: pre-wrap;\"># coding: utf-8\r\n\r\nimport sys, os\r\nsys.path.append(os.pardir)  # &#35242;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12398;&#12501;&#12449;&#12452;&#12523;&#12434;&#12452;&#12531;&#12509;&#12540;&#12488;&#12377;&#12427;&#12383;&#12417;&#12398;&#35373;&#23450;\r\nsys.path.append('..')\r\n\r\n\r\nimport time\r\n\r\n\r\ntimestamp = int(time.time()*1000000)\r\n\r\nhead = \"tmp\" + str(timestamp)\r\n\r\n#head = 'tmp'\r\n\r\nprint(head)\r\n\r\nlogfile = open(head + '.log','w')\r\n\r\nlogfile.write( head + '\\n\\n')\r\n\r\ntexWord = '\\\\frac{1}{\\\\sqrt{2}}'\r\n#texWord = repr('\\frac{1}{\\sqrt{2}}')\r\n\r\nlogfile.write( 'TeX : ' + texWord + '\\n\\n')\r\n\r\nprint('texWord : ' + texWord)\r\n\r\ntexfile = open(head + '.tex','w')\r\n\r\ntmpString = '''\\\\documentclass{{jarticle}}\r\n\\\\special{{papersize=73mm,40mm}}\r\n\\\\setlength{{\\\\hoffset}}{{-20.0mm}}\r\n\\\\setlength{{\\\\voffset}}{{-14.9mm}}\r\n\\\\setlength{{\\\\oddsidemargin}}{{0mm}}\r\n\\\\setlength{{\\\\topmargin}}{{0mm}}\r\n\\\\setlength{{\\\\headheight}}{{0mm}}\r\n\\\\setlength{{\\\\headsep}}{{0mm}}\r\n\\\\setlength{{\\\\textwidth}}{{72mm}}\r\n\\\\setlength{{\\\\textheight}}{{13mm}}\r\n\\\\setlength{{\\\\unitlength}}{{1mm}}\r\n\\\\pagestyle{{empty}}\r\n\\\\begin{{document}}\r\n%\\\\makebox&#12434;&#20351;&#12358;&#12392;&#31665;&#12434;&#26360;&#12363;&#12394;&#12356;\r\n%\\\\framebox&#12434;&#20351;&#12358;&#12392;&#31665;&#12434;&#26360;&#12367;\r\n\\\\noindent\r\n\\\\makebox(71,13)[l]{{{{\\\\Huge \\\\quad $ \\\\displaystyle {word} $ }}}}\r\n%makeswfp.php&#12392;&#30064;&#12394;&#12426;&#12289;&#19978;&#35352;tex&#12477;&#12540;&#12473;&#12434;$ $ &#12391;&#25375;&#12416;&#24517;&#35201;&#12364;&#12354;&#12427;&#12290;\r\n\\\\end{{document}}\r\n\r\n'''.format(word = texWord)\r\n\r\ntexfile.write(tmpString)\r\n\r\ntexfile.close()\r\n\r\n\r\ntmpCmd = 'platex .\/' + head + '.tex &gt; \/dev\/null'\r\nprint(tmpCmd)\r\nos.system(tmpCmd)\r\n\r\n#tmpCmd = 'dvipdfmx -f .\/ipa.map .\/' + head + '.dvi'\r\n#print(tmpCmd)\r\n#os.system(tmpCmd)\r\n\r\n\r\n# &#27161;&#28310;&#12456;&#12521;&#12540;&#20986;&#21147;&#12394;&#12393;&#12434;&#25448;&#12390;&#12427;\r\n\r\ntmpCmd = 'dvips -E -Ppdf .\/' + head + '.dvi -o .\/' + head + '.eps 2&gt;&gt; \/dev\/null'\r\nprint(tmpCmd)\r\nos.system(tmpCmd)\r\n\r\ntmpCmd = 'convert .\/' + head + '.eps .\/' + head + '.png 2&gt;&gt; \/dev\/null'\r\nprint(tmpCmd)\r\nos.system(tmpCmd)\r\n\r\n\r\nlogfile.close()<\/code><\/pre>\n<p>\u4ed6\u306e\u3084\u308a\u65b9\u3067 \u753b\u50cf\u3092\u4f5c\u3063\u3066\u307f\u307e\u3059\u3002synaptic \u304b\u3089 dvipng \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u5fc5\u8981\u3067\u3057\u305f\u3002<\/p>\n<pre><code style=\"color: midnightblue; font-size: 12px; white-space: pre-wrap;\">%reset -f\r\n\r\nimport sys\r\n#from sympy import *\r\nimport sympy\r\nimport random\r\nfrom sympy import I, pi, E\r\n\r\nexpr = sympy.sympify('x\/y', evaluate=False)\r\n\r\nsympy.preview(expr, viewer='file', filename='.\/texImage\/tex.png', euler=False,\\\r\n              dvioptions=[\"-T\", \"tight\", \"-z\", \"0\", \"--truecolor\", \"-D 600\"])<\/code><\/pre>\n<p>\uff11\u884c\u304c\u9577\u3044\u306e\u3067\u6539\u884c\u3084\u30a4\u30f3\u30c7\u30f3\u30c8\u304c\u3080\u3061\u3083\u304f\u3061\u3083\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002preview \u306b sympy \u306e\u5f0f\u3092\u4e0e\u3048\u3066\u3044\u307e\u3059\u3002TeX \u306e\u30bd\u30fc\u30b9\u3067\u3082\u826f\u3044\u3088\u3046\u3067\u3059\u304c\u3001\u66f8\u304d\u65b9\u304c\u7570\u306a\u308a\u307e\u3059\uff08<a href=\"https:\/\/www.wizard-notes.com\/entry\/python\/sympy-save-tex-equation\">\u53c2\u8003\u30b5\u30a4\u30c8<\/a>\uff09\u3002<\/p>\n<p>\u753b\u50cf\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/wp-content\/uploads\/2023\/11\/tex.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/wp-content\/uploads\/2023\/11\/tex.png\" alt=\"\" width=\"56\" height=\"200\" class=\"aligncenter size-full wp-image-12330\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6570\u5f0f\u306e\u753b\u50cf\u3092\u305f\u304f\u3055\u3093\u4f5c\u308b\u6e96\u5099\u3067\u3059\u3002\u307e\u305a ubuntu22 \u306b\u3044\u304f\u3064\u304b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb &#8230; <a class=\"more-link\" href=\"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=12253\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-12253","post","type-post","status-publish","format-standard","hentry","category-column"],"_links":{"self":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/12253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12253"}],"version-history":[{"count":8,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/12253\/revisions"}],"predecessor-version":[{"id":12331,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/12253\/revisions\/12331"}],"wp:attachment":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12253"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}