キンドルがMathMLに対応したってよ。数式の入った本が作りやすくなるだろうってこと。MathMLはXMLベースのHTML5タグで数式を表現できる。今まで画像で表現するよりもタグで書いたほうが扱いやすい。
MathMLに対応しただけですべて使えるわけではなく、一部使えないものもあるらしいよ。
サポートされていないタグ:
annotation
maction
mglyph
mlongdiv
msgroup
mstack
semantics
以前、MathMLが使えなかったときに、PNGやSVGで工夫して作ろうとしてたのを、MathMLを使ってEPUBにしてみようと思う。
問題はどうやってTeXからMathMLに変換するかである。ツールとしてはまず、TeXからMathMLに変換する。
https://www.mathtowebonline.com/
と手書きで数式を認識してくれる。
とがある。
数式では、文字の間に表示するinlineと数式単体で表示するblockがある。
https://developer.mozilla.org/ja/docs/Web/MathML/Element/math
EPUB3ではXHTMLで表示するので、mathタグに<math xmlns="http://www.w3.org/1998/Math/MathML">XMLの名前空間を指定する。
inlineの場合は次のように記述する。
<math xmlns="http://www.w3.org/1998/Math/MathML"
display="inline">
E=-n\dfrac {d\phi } {dt}
d\psi=Blvdt
d\phi =Bndtl
E=Bvl
\psi =nBS\cos \theta
psi =nBS\cos \omega t
e =-\dfrac {d\psi } {dt}
<!-- begin MathToWeb --><!-- begin MathToWeb --><!-- (your LaTeX) $E=-n\dfrac {d\phi } {dt}$ --><math xmlns="http://www.w3.org/1998/Math/MathML"><mrow> <mi>E</mi> <mo>=</mo> <mo>-</mo> <mi>n</mi> <mstyle scriptlevel="0" displaystyle="true"> <mrow> <mfrac linethickness="1"> <mrow> <mo>ⅆ</mo> <mi>ϕ</mi> </mrow> <mrow> <mo>ⅆ</mo> <mi>t</mi> </mrow> </mfrac> </mrow> </mstyle></mrow></math><!-- end MathToWeb -->
<!-- begin MathToWeb --><!-- begin MathToWeb --><!-- (your LaTeX) $d\psi=Blvdt$ --><math xmlns="http://www.w3.org/1998/Math/MathML"><mrow> <mo>ⅆ</mo> <mi>ψ</mi> <mo>=</mo> <mi>B</mi> <mi>l</mi> <mi>v</mi> <mo>ⅆ</mo> <mi>t</mi></mrow></math><!-- end MathToWeb -->
<!-- begin MathToWeb --><!-- begin MathToWeb --><!-- (your LaTeX) $d\phi =Bndtl$ --><math xmlns="http://www.w3.org/1998/Math/MathML"><mrow> <mo>ⅆ</mo> <mi>ϕ</mi> <mo>=</mo> <mi>B</mi> <mi>n</mi> <mo>ⅆ</mo> <mi>t</mi> <mi>l</mi></mrow></math><!-- end MathToWeb -->
<!-- begin MathToWeb --><!-- begin MathToWeb --><!-- (your LaTeX) $E=Bvl$ --><math xmlns="http://www.w3.org/1998/Math/MathML"><mrow> <mi>E</mi> <mo>=</mo> <mi>B</mi> <mi>v</mi> <mi>l</mi></mrow></math><!-- end MathToWeb -->
MathML should either have an 'alttext' attribute or 'annotation-xml' child element.
MathMLが表示できない場合の代替表示が必要ってことかな。
texの場合は<annotation encoding="application/x-tex"> </annotation>
画像の場合は <annotation encoding="image/png" src="alt.png"/>
みたいにすればいいかな。
ただし、semanticsとannotationはキンドルではまだサポートされていない。
OPFのエラーはitemにproperties="mathml"を追加すると消えた。
(2) OPFファイルには、数式を含むXHTMLファイルを参照するitem要素にはproperties="mathml"を指定すること。
例)<item href="201305211138.xhtml" id="id201305211138" media-type="application/xhtml+xml" properties="mathml"/>4.MathMLの表示:ブロック数式とインライン数式
参考:
EPUBリーダで、MathMLで記述した数式がだいぶ表示できるようになりました。 | 電子書籍、電子出版のCAS-UBブログ
Readiumでは意図した表示になるが、kindle Previewerでは表示が崩れてしまっている。マクスウェル方程式どこいった。
kindle Previewer2.9での表示では、display="block"や分数が表示できていない。
新しく出た、Kindle Previewer3のベータ版が下のリンクよりダウンロードできる。
Kindle Previewer3での表示の確認。表示自体はましになったが、なぜか微分を表すdが消えている。