Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 10-31-2016, 11:49 AM   #1
PascP
Junior Member
PascP began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Oct 2016
Device: iphone
Problem with math equations

Hello,

I've tried to make an epub from a website using calibre so I can read it offline. The website containts a lot of math and equations. Now, my problem is that calibre shows some of the math but not all of them, and i dont mean that it shows them twisted or unformated but not at all. Also when i press F5 to refresh the ebook the reader displays "Typesetting Math" and loads from 0% to 100%. at around 20-50% the math types are beeing displayed but when it reaches 100% they disapear again. I have included below some text with math equations. the first usualy works and the second usualy doesnt get displayed.


Code:
<p>Now we can define <span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>h</mi><mi mathvariant="italic">θ</mi></msub><mo stretchy="false">(</mo><mi>X</mi><mo stretchy="false">)</mo></math></span><script id="MathJax-Element-18" type="math/tex">h_\theta(X)</script> as a row vector that gives the value of <span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>h</mi><mi mathvariant="italic">θ</mi></msub><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></math></span><script id="MathJax-Element-19" type="math/tex">h_\theta(x)</script> at each of the <span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>m</mi></math></span><script id="MathJax-Element-20" type="math/tex">m</script> training examples:</p>
<p><span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mtable minlabelspacing=".8em" side="right" displaystyle="true" columnspacing="0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em" rowspacing="3pt" columnalign="right left right left right left right left right left right left"><mtr><mtd><msub><mi>h</mi><mi mathvariant="italic">θ</mi></msub><mo stretchy="false">(</mo><mi>X</mi><mo stretchy="false">)</mo><mo stretchy="false">=</mo><mfenced close="]" open="["><mtable columnspacing="1em" rowspacing="4pt" columnalign="center"><mtr><mtd><msub><mi mathvariant="italic">θ</mi><mn>0</mn></msub><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup><mo stretchy="false">+</mo><msub><mi mathvariant="italic">θ</mi><mn>1</mn></msub><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup><mo stretchy="false">+</mo><mo>.</mo><mo>.</mo><mo>.</mo><mo stretchy="false">+</mo><msub><mi mathvariant="italic">θ</mi><mi>n</mi></msub><msubsup><mi>x</mi><mi>n</mi><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="3em"/><msub><mi mathvariant="italic">θ</mi><mn>0</mn></msub><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup><mo stretchy="false">+</mo><msub><mi mathvariant="italic">θ</mi><mn>1</mn></msub><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup><mo stretchy="false">+</mo><mo>.</mo><mo>.</mo><mo>.</mo><mo stretchy="false">+</mo><msub><mi mathvariant="italic">θ</mi><mi>n</mi></msub><msubsup><mi>x</mi><mi>n</mi><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="3em"/><mo>.</mo><mo>.</mo><mo>.</mo><mspace width="3em"/><msub><mi mathvariant="italic">θ</mi><mn>0</mn></msub><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mi>m</mi><mo stretchy="false">)</mo></mrow></msubsup><mo stretchy="false">+</mo><msub><mi mathvariant="italic">θ</mi><mn>1</mn></msub><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mi>m</mi><mo stretchy="false">)</mo></mrow></msubsup><mo stretchy="false">+</mo><mo>.</mo><mo>.</mo><mo>.</mo><mo stretchy="false">+</mo><msub><mi mathvariant="italic">θ</mi><mi>n</mi></msub><msubsup><mi>x</mi><mi>n</mi><mrow><mo stretchy="false">(</mo><mi>m</mi><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr></mtable></mfenced></mtd></mtr></mtable></math></span><script id="MathJax-Element-21" type="math/tex">
\begin{align*}
h_\theta(X) =
\begin{bmatrix}
\theta_0 x^{(1)}_0 + \theta_1 x^{(1)}_1 + ... + \theta_n x^{(1)}_n \hspace{3em}
\theta_0 x^{(2)}_0 + \theta_1 x^{(2)}_1 + ... + \theta_n x^{(2)}_n \hspace{3em} ... \hspace{3em}
\theta_0  x^{(m)}_0 + \theta_1 x^{(m)}_1 + ... + \theta_n x^{(m)}_n \newline
\end{bmatrix}
\end{align*}
</script></p>
<p>But again using the definition of matrix multiplication, we can represent this more concisely:</p>
<p><span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mtable minlabelspacing=".8em" side="right" displaystyle="true" columnspacing="0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em" rowspacing="3pt" columnalign="right left right left right left right left right left right left"><mtr><mtd><msub><mi>h</mi><mi mathvariant="italic">θ</mi></msub><mo stretchy="false">(</mo><mi>X</mi><mo stretchy="false">)</mo><mo stretchy="false">=</mo><mfenced close="]" open="["><mtable columnspacing="1em" rowspacing="4pt" columnalign="center"><mtr><mtd><msub><mi mathvariant="italic">θ</mi><mn>0</mn></msub><mspace width="2em"/><msub><mi mathvariant="italic">θ</mi><mn>1</mn></msub><mspace width="2em"/><mo>.</mo><mo>.</mo><mo>.</mo><mspace width="2em"/><msub><mi mathvariant="italic">θ</mi><mi>n</mi></msub></mtd></mtr></mtable></mfenced><mfenced close="]" open="["><mtable columnspacing="1em" rowspacing="4pt" columnalign="center"><mtr><mtd><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="2em"/><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="2em"/><mo>.</mo><mo>.</mo><mo>.</mo><mspace width="2em"/><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mi>m</mi><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr><mtr><mtd><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="2em"/><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="2em"/><mo>.</mo><mo>.</mo><mo>.</mo><mspace width="2em"/><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mi>m</mi><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr><mtr><mtd><mo stretchy="false">⋮</mo></mtd></mtr><mtr><mtd><msubsup><mi>x</mi><mi>n</mi><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="2em"/><msubsup><mi>x</mi><mi>n</mi><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup><mspace width="2em"/><mo>.</mo><mo>.</mo><mo>.</mo><mspace width="2em"/><msubsup><mi>x</mi><mi>n</mi><mrow><mo stretchy="false">(</mo><mi>m</mi><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr></mtable></mfenced><mo stretchy="false">=</mo><msup><mi mathvariant="italic">θ</mi><mi>T</mi></msup><mi>X</mi></mtd></mtr></mtable></math></span><script id="MathJax-Element-22" type="math/tex">
\begin{align*}
h_\theta(X) =
\begin{bmatrix}
\theta_0 \hspace{2em}  \theta_1 \hspace{2em} ... \hspace{2em} \theta_n
\end{bmatrix}
\begin{bmatrix}
x^{(1)}_0 \hspace{2em} x^{(2)}_0\hspace{2em}  ... \hspace{2em} x^{(m)}_0 \newline
x^{(1)}_1 \hspace{2em} x^{(2)}_1 \hspace{2em} ... \hspace{2em} x^{(m)}_1 \newline
\vdots \newline
x^{(1)}_n \hspace{2em} x^{(2)}_n \hspace{2em} ... \hspace{2em} x^{(m)}_n \newline
\end{bmatrix}=
\theta^T X
\end{align*} 
</script></p>
<p><strong>Note</strong>: this version of the hypothesis function assumes the matrix <span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>X</mi></math></span><script id="MathJax-Element-23" type="math/tex">X</script> and vector <span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="italic">θ</mi></math></span><script id="MathJax-Element-24" type="math/tex">\theta</script> store their values as follows:</p>
<p><span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mtable minlabelspacing=".8em" side="right" displaystyle="true" columnspacing="0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em" rowspacing="3pt" columnalign="right left right left right left right left right left right left"><mtr><mtd><mi>X</mi><mo stretchy="false">=</mo><mfenced close="]" open="["><mtable columnspacing="1em" rowspacing="4pt" columnalign="center"><mtr><mtd><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd><mtd><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd><mtd><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>3</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr><mtr><mtd><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd><mtd><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd><mtd><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>3</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr></mtable></mfenced></mtd><mtd><mo stretchy="false">,</mo><mi mathvariant="italic">θ</mi><mo stretchy="false">=</mo><mfenced close="]" open="["><mtable columnspacing="1em" rowspacing="4pt" columnalign="center"><mtr><mtd><msub><mi mathvariant="italic">θ</mi><mn>0</mn></msub></mtd></mtr><mtr><mtd><msub><mi mathvariant="italic">θ</mi><mn>1</mn></msub></mtd></mtr></mtable></mfenced></mtd></mtr></mtable></math></span><script id="MathJax-Element-25" type="math/tex">
\begin{align*}
X = 
\begin{bmatrix}
x^{(1)}_0  x^{(2)}_0  x^{(3)}_0  \newline
x^{(1)}_1  x^{(2)}_1  x^{(3)}_1 
\end{bmatrix}

,\theta = 
\begin{bmatrix}
\theta_0 \newline
\theta_1 \newline
\end{bmatrix}
\end{align*}
</script></p>
<p>You might instead store the training examples in <span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>X</mi></math></span><script id="MathJax-Element-26" type="math/tex">X</script> row-wise, like such:</p>
<p><span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mtable minlabelspacing=".8em" side="right" displaystyle="true" columnspacing="0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em" rowspacing="3pt" columnalign="right left right left right left right left right left right left"><mtr><mtd><mi>X</mi><mo stretchy="false">=</mo><mfenced close="]" open="["><mtable columnspacing="1em" rowspacing="4pt" columnalign="center"><mtr><mtd><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd><mtd><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr><mtr><mtd><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd><mtd><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr><mtr><mtd><msubsup><mi>x</mi><mn>0</mn><mrow><mo stretchy="false">(</mo><mn>3</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd><mtd><msubsup><mi>x</mi><mn>1</mn><mrow><mo stretchy="false">(</mo><mn>3</mn><mo stretchy="false">)</mo></mrow></msubsup></mtd></mtr></mtable></mfenced></mtd><mtd><mo stretchy="false">,</mo><mi mathvariant="italic">θ</mi><mo stretchy="false">=</mo><mfenced close="]" open="["><mtable columnspacing="1em" rowspacing="4pt" columnalign="center"><mtr><mtd><msub><mi mathvariant="italic">θ</mi><mn>0</mn></msub></mtd></mtr><mtr><mtd><msub><mi mathvariant="italic">θ</mi><mn>1</mn></msub></mtd></mtr></mtable></mfenced></mtd></mtr></mtable></math></span><script id="MathJax-Element-27" type="math/tex">
\begin{align*}
X = 
\begin{bmatrix}
x^{(1)}_0  x^{(1)}_1  \newline
x^{(2)}_0  x^{(2)}_1  \newline
x^{(3)}_0  x^{(3)}_1 
\end{bmatrix}

,\theta = 
\begin{bmatrix}
\theta_0 \newline
\theta_1 \newline
\end{bmatrix}
\end{align*}
</script></p>

Code:
<h2 id="uKMKRwShqcolDYwBCCqBGWG"> <span class="mw-headline" id="Hypothesis_Representation">Hypothesis Representation</span></h2>
<p>Our hypothesis should satisfy:</p>
<p><span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathsize="1.2em"><mn>0</mn><mo stretchy="false">≤</mo><msub><mi>h</mi><mi mathvariant="italic">θ</mi></msub><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo stretchy="false">≤</mo><mn>1</mn></mstyle></math></span><script id="MathJax-Element-4" type="math/tex">
\large
0 \leq h_\theta (x) \leq 1
</script></p>
<p>Our new form uses the "Sigmoid Function," also called the "Logistic Function":</p>
<p><span style="display: none;" class="MathJax_Preview"></span><span style="font-size: 100%;" class="MathJax_MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathsize="1.2em"><mtable minlabelspacing=".8em" side="right" displaystyle="true" columnspacing="0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em 2em 0.2777777777777778em" rowspacing="3pt" columnalign="right left right left right left right left right left right left"><mtr><mtd/><mtd><msub><mi>h</mi><mi mathvariant="italic">θ</mi></msub><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo stretchy="false">=</mo><mi>g</mi><mo stretchy="false">(</mo><msup><mi mathvariant="italic">θ</mi><mi>T</mi></msup><mi>x</mi><mo stretchy="false">)</mo></mtd></mtr><mtr><mtd/></mtr><mtr><mtd/><mtd><mi>z</mi><mo stretchy="false">=</mo><msup><mi mathvariant="italic">θ</mi><mi>T</mi></msup><mi>x</mi></mtd></mtr><mtr><mtd/><mtd><mi>g</mi><mo stretchy="false">(</mo><mi>z</mi><mo stretchy="false">)</mo><mo stretchy="false">=</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac><mn>1</mn><mrow><mn>1</mn><mo stretchy="false">+</mo><msup><mi>e</mi><mrow><mo stretchy="false">−</mo><mi>z</mi></mrow></msup></mrow></mfrac></mstyle></mtd></mtr></mtable></mstyle></math></span><script id="MathJax-Element-5" type="math/tex">
\large
\begin{align*}
 h_\theta (x) =  g ( \theta^T x ) \newline \newline
 z = \theta^T x \newline
 g(z) = \dfrac{1}{1 + e^{-z}}
\end{align*}
</script></p>
Do you guys have any idea why is this happening? Thank you!!!
PascP is offline   Reply With Quote
Old 10-31-2016, 12:47 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,909
Karma: 22669818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I doubt very much you'll be able to directly take a website with math and get it to render correctly in the viewer. It depends very much on how mathjax is called, what css is used what output jax is used, etc. And looking at the html extract you posted its looks like the postprocessed output from mathjax, not the original markup, which is even less likely to work.

Your best bet is using either mathml for embedded latex/asciimath ina simple html page, like the example here: https://manual.calibre-ebook.com/typesetting_math.html
kovidgoyal is offline   Reply With Quote
Advert
Old 11-05-2016, 04:34 PM   #3
PascP
Junior Member
PascP began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Oct 2016
Device: iphone
Hello, thank you for your reply and for the great software .
So do you suggest that the best solution would be to rewrite all the equations in the format used in the link? it will take a long time... I suspected that the format I used was the problem but I cant understand why some equations get displayed and others don't, as well as why even thought the are visible for a sort time then they disappear
PascP is offline   Reply With Quote
Old 11-17-2016, 09:06 AM   #4
paulKwanlunique
Junior Member
paulKwanlunique is a jewel in the roughpaulKwanlunique is a jewel in the roughpaulKwanlunique is a jewel in the roughpaulKwanlunique is a jewel in the roughpaulKwanlunique is a jewel in the roughpaulKwanlunique is a jewel in the roughpaulKwanlunique is a jewel in the roughpaulKwanlunique is a jewel in the roughpaulKwanlunique is a jewel in the roughpaulKwanlunique is a jewel in the roughpaulKwanlunique is a jewel in the rough
 
Posts: 3
Karma: 7134
Join Date: Nov 2016
Device: none
Quote:
Originally Posted by kovidgoyal View Post
Your best bet is using either mathml for embedded latex/asciimath ina simple html page, like the example here: https://manual.calibre-ebook.com/typesetting_math.html

ThX you for tips
paulKwanlunique is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Math Equations are Unreadable rwstowe Conversion 2 11-23-2015 09:58 PM
Problem of math formula when converting azw3 to pdf maffia Conversion 1 05-15-2015 08:38 PM
Vector graphics and math equations rplantz ePub 2 07-23-2011 01:50 PM
Conversion with equations achmorrison Conversion 2 05-12-2011 11:38 AM
PRS-505 Math equations luma Sony Reader 4 06-04-2010 07:44 AM


All times are GMT -4. The time now is 08:11 AM.


MobileRead.com is a privately owned, operated and funded community.