「TeX数式のチェック」の版間の差分
細編集の要約なし |
SyntaxHighlightにcopyの追加 |
||
| (同じ利用者による、間の7版が非表示) | |||
| 1行目: | 1行目: | ||
TeX形式で記述した数式を画像でチェックできます。確認したいTeXコードを選択してマクロを実行してください。 | |||
< | Google Chart APIを利用したバージョンとMathjavを利用したバージョンがあります。 | ||
== 注意事項 == | |||
このマクロはInternet Explorer上で動作しますが、Internet Explorerのサポートは2022年6月16日に終了したため、このマクロを使用することはおすすめしません。 | |||
== Google Chart APIを利用したバージョン == | |||
Googleは本機能を非推奨に分類しています。ご承知おきください。<cite>[https://google-developers.appspot.com/chart/infographics/ The Infographics portion of Google Chart Tools has been officially deprecated as of April 20, 2012. It will continue to work as per our deprecation policy.]</cite> | |||
クリップボードに<img>タグの内容がコピーされます。 | |||
<syntaxhighlight lang="javascript" copy> | |||
// GetFormulaImage.js | // GetFormulaImage.js | ||
// | // 2013-10-21 | ||
var baseURL_google = 'http://chart.apis.google.com/chart?cht=tx&chl='; | var baseURL_google = 'http://chart.apis.google.com/chart?cht=tx&chl='; | ||
var url = baseURL_google; | var url = baseURL_google; | ||
var objIE = new ActiveXObject( "InternetExplorer.Application" ); | var objIE = new ActiveXObject("InternetExplorer.Application"); | ||
var sel = | var sel = editor.ActiveDocument.selection; | ||
if ( sel.IsEmpty ){ | if (sel.IsEmpty) { | ||
Quit(); | |||
} else { | } else { | ||
var encoded_TeXcode = encodeURIComponent(sel.Text); | |||
url += encoded_TeXcode; | |||
}; | } | ||
ClipboardData.SetData("<img alt=\"" + sel.Text + "\"" + " src=\"" + url + "\"/> "); | |||
objIE.Width = 300; | |||
objIE.Height = 200; | |||
objIE.AddressBar = false; | |||
objIE.MenuBar = false; | |||
objIE.StatusBar = false; | |||
objIE.ToolBar = false; | |||
objIE.Navigate(url); | |||
objIE.Visible = true; | |||
</syntaxhighlight> | |||
元のTeXコードも一緒に見たい場合は、 | |||
<syntaxhighlight lang="javascript"> | |||
objIE.Navigate(url); | |||
</syntaxhighlight> | |||
の部分を | |||
<syntaxhighlight lang="javascript"> | |||
objIE.Navigate("about:blank"); | |||
objIE.document.write("<html><head></head><body>" + "<img src='" + url +"'/><br /><br />" + sel.Text + "</body></html>"); | |||
</syntaxhighlight> | |||
と変更してください。 | |||
== Mathjavを利用したバージョン == | |||
画像のコピーはできません。 | |||
表示部を右クリックすると、メニューがポップアップします。そこからTeXコードとMathMLコードが得られます。 | |||
< | <syntaxhighlight lang="javascript" copy> | ||
// GetFormulaImage_Mathjav.js | // GetFormulaImage_Mathjav.js | ||
// | // 2013-10-21 | ||
var objIE = new ActiveXObject( "InternetExplorer.Application" ); | var objIE = new ActiveXObject("InternetExplorer.Application"); | ||
var sel = | var sel = editor.ActiveDocument.selection; | ||
if ( sel.IsEmpty ){ Quit() } | if (sel.IsEmpty) { | ||
Quit(); | |||
} | |||
objIE.Width = 200; | |||
objIE.Height = 150; | |||
objIE.AddressBar = false; | |||
objIE.MenuBar = false; | |||
objIE.StatusBar = false; | |||
objIE.ToolBar = false; | |||
objIE.Navigate("about:blank"); | |||
objIE.document.write("<html><head>"); | |||
objIE.document.write("<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML'></script>"); | |||
objIE.document.write("</head><body>"); | |||
objIE.document.write("<br />\\(" + sel.Text + "\\)<br />"); | |||
objIE.document.write("</body></html>"); | |||
objIE.refresh(); | |||
objIE.Visible = true; | |||
</syntaxhighlight> | |||
</ | |||
スポンサーリンク