Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
8
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

@rbtnn

GoogleAPIでTexを使う。

<div class='tex'>なタグをすべて、GoogleAPIで数式画像を生成し、imgタグに置換するコードです。
<div class='tex'>なタグの中身はTexのコード。
jQueryのeachメソッド使うことで簡単に画像に置換できるのは便利ですね...。

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  </head>
  <body>

<div class='tex'>
f(x)=\int_0^{x}g(t)\,dt
</div>

<div class='tex'>
\frac{d^2\phi(x)}{dx^2} = 
\frac{2m}{\hbar^2} \bigl\{ \frac{1}{2}m\omega^2 x^2 - E \bigr\} \phi(x)
</div>

<script type='text/javascript'>
$('.tex').each(function(i,obj){
  var base = 'http://chart.apis.google.com/chart?cht=tx&chl=';
  var url = base + encodeURIComponent($(obj).html());
  $('<img>').attr('src',url).insertAfter(obj);
  $(obj).remove();
});
</script>

  </body>
</html>
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
8
Help us understand the problem. What are the problem?