KDP(電子出版)のメモ 急急如律令

Amazon Kindleダイレクト・パブリッシングでの電子出版や電子書籍の作成販売について、文章やイラストの作成や編集方法について書いています。

キンドルがMathMLに対応したので、数式を使った本を作ってみた。

 キンドルがMathMLに対応したってよ。数式の入った本が作りやすくなるだろうってこと。MathMLはXMLベースのHTML5タグで数式を表現できる。今まで画像で表現するよりもタグで書いたほうが扱いやすい。

 

hon.jp

MathMLに対応しただけですべて使えるわけではなく、一部使えないものもあるらしいよ。

サポートされていないタグ:
annotation
maction
mglyph
mlongdiv
msgroup
mstack
semantics

 

 以前、MathMLが使えなかったときに、PNGやSVGで工夫して作ろうとしてたのを、MathMLを使ってEPUBにしてみようと思う。

99nyorituryo.hatenablog.com

 問題はどうやってTeXからMathMLに変換するかである。ツールとしてはまず、TeXからMathMLに変換する。

https://www.mathtowebonline.com/

 と手書きで数式を認識してくれる。

Web EquationMath

とがある。

 数式では、文字の間に表示する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>&#x02146;</mo> <mi>&#x003D5;</mi> </mrow> <mrow> <mo>&#x02146;</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>&#x02146;</mo> <mi>&#x003C8;</mi> <mo>=</mo> <mi>B</mi> <mi>l</mi> <mi>v</mi> <mo>&#x02146;</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>&#x02146;</mo> <mi>&#x003D5;</mi> <mo>=</mo> <mi>B</mi> <mi>n</mi> <mo>&#x02146;</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 -->

 

github.com

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はキンドルではまだサポートされていない。

 

developer.mozilla.org

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では表示が崩れてしまっている。マクスウェル方程式どこいった。

f:id:kyukyunyorituryo:20180727234013j:plain

 

kindle Previewer2.9での表示では、display="block"や分数が表示できていない。

f:id:kyukyunyorituryo:20180727234002j:plain

 新しく出た、Kindle Previewer3のベータ版が下のリンクよりダウンロードできる。

Kindle Previewerのベータ版

 

Kindle Previewer3での表示の確認。表示自体はましになったが、なぜか微分を表すdが消えている。

 

f:id:kyukyunyorituryo:20180730144240j:plain

 

github.com

MathML2.0メモ

 

[改訂第7版]LaTeX2ε美文書作成入門

[改訂第7版]LaTeX2ε美文書作成入門

 

 

blog.livedoor.jp