public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* TexShop produces a great pdf, but pandoc has trouble with matrix converting to epub
@ 2018-12-11 16:54 Marc Grober
       [not found] ` <8bc56eec-9afe-43ff-9847-a9f3150be1d6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Grober @ 2018-12-11 16:54 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1315 bytes --]


 I am running   
pandoc Matrices.tex -o matrices.epub -f latex -t epub3

This produces the expected pdf with the following lines:
\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{\hskip -\arraycolsep \let\
@ifnextchar\new@ifnextchar \array{#1}}
\makeatother 
$$\begin{bmatrix}[rrr|r] 1 & 0 & 0 & \frac{78}{29} \\ 0 & 1 & 0 & \frac{64}{
87} \\ 0 & 0 & 1 & -\frac{10}{29} \end{bmatrix}$$


[image: Screen Shot 2018-12-11 at 7.35.19 AM.png]


but not the epub using Azardi, calibre or ibooks

[image: Screen Shot 2018-12-11 at 7.33.58 AM.png]
I understand this is not a Latex group, but the tex seems to be working 
just fine...

or is this one of those tex flavor gotchas, where pandoc has trouble with 
the particular tex used?

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/8bc56eec-9afe-43ff-9847-a9f3150be1d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 10238 bytes --]

[-- Attachment #2: Screen Shot 2018-12-11 at 7.35.19 AM.png --]
[-- Type: image/png, Size: 19599 bytes --]

[-- Attachment #3: Screen Shot 2018-12-11 at 7.33.58 AM.png --]
[-- Type: image/png, Size: 21340 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: TexShop produces a great pdf, but pandoc has trouble with matrix converting to epub
       [not found] ` <8bc56eec-9afe-43ff-9847-a9f3150be1d6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2018-12-11 18:47   ` John MacFarlane
       [not found]     ` <yh480kefanj3yq.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: John MacFarlane @ 2018-12-11 18:47 UTC (permalink / raw)
  To: Marc Grober, pandoc-discuss


EPUB3 supports math encoded using MathML; however, not
all EPUB readers can handle this.  (The ones you're
using may be among them.)

EPUB2 doesn't handle math at all, though you could try
with `--webtex`.

Marc Grober <marc.grober-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

>  I am running   
> pandoc Matrices.tex -o matrices.epub -f latex -t epub3
>
> This produces the expected pdf with the following lines:
> \makeatletter
> \renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{\hskip -\arraycolsep \let\
> @ifnextchar\new@ifnextchar \array{#1}}
> \makeatother 
> $$\begin{bmatrix}[rrr|r] 1 & 0 & 0 & \frac{78}{29} \\ 0 & 1 & 0 & \frac{64}{
> 87} \\ 0 & 0 & 1 & -\frac{10}{29} \end{bmatrix}$$
>
>
> [image: Screen Shot 2018-12-11 at 7.35.19 AM.png]
>
>
> but not the epub using Azardi, calibre or ibooks
>
> [image: Screen Shot 2018-12-11 at 7.33.58 AM.png]
> I understand this is not a Latex group, but the tex seems to be working 
> just fine...
>
> or is this one of those tex flavor gotchas, where pandoc has trouble with 
> the particular tex used?
>
> -- 
> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/8bc56eec-9afe-43ff-9847-a9f3150be1d6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: TexShop produces a great pdf, but pandoc has trouble with matrix converting to epub
       [not found]     ` <yh480kefanj3yq.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2018-12-11 21:48       ` Marc Grober
       [not found]         ` <d6690715-52c8-3e7e-5345-75a70d1fda35-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Grober @ 2018-12-11 21:48 UTC (permalink / raw)
  To: John MacFarlane, pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 5396 bytes --]

All three of the readers handle MathML, and as noted in the images,
handle most of the math fine, just not the alignment.

If I use code in a manner that will allow mathjax to produce mathml,
like so:

$$begin{array}{rrr|r}1 & 2 & 4 & 8 \\16 & 32 & 64 & 128 \\256 & 512 &
1024 & 2048\end{array}\right]$$

Mathjax produces

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mstyle>
    <mrow class="MJX-TeXAtom-ORD">
      <mrow>
        <mo>[</mo>
        <mtable columnalign="right right right right" rowspacing="4pt"
columnspacing="1em" columnlines="none none solid">
          <mtr>
            <mtd>
              <mn>1</mn>
            </mtd>
            <mtd>
              <mn>2</mn>
            </mtd>
            <mtd>
              <mn>4</mn>
            </mtd>
            <mtd>
              <mn>8</mn>
            </mtd>
          </mtr>
          <mtr>
            <mtd>
              <mn>16</mn>
            </mtd>
            <mtd>
              <mn>32</mn>
            </mtd>
            <mtd>
              <mn>64</mn>
            </mtd>
            <mtd>
              <mn>128</mn>
            </mtd>
          </mtr>
          <mtr>
            <mtd>
              <mn>256</mn>
            </mtd>
            <mtd>
              <mn>512</mn>
            </mtd>
            <mtd>
              <mn>1024</mn>
            </mtd>
            <mtd>
              <mn>2048</mn>
            </mtd>
          </mtr>
        </mtable>
        <mo>]</mo>
      </mrow>
    </mrow>
  </mstyle>
</math>

So the tex not only sets properly in mathjax, it works correctly in
TexShop, BUT it still does not work in pandoc.

That means that I am passing pandoc good texm, but pandoc is not
handling it correctly for some reason and is outputting inadequate MathML.

And curiously enough, if I use pandoc to output the tex into pdf, the
initial code does not work, but the altered code that works in MathML
and produces the MathML above DOES work.

Now, if I take the MathML that Mathjax produces, and paste it into the
ebook that is displaying incorrectly,

VOILA!

everything works just fine.

Here is the MathML that pandoc creates:

<math display="block"
xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo stretchy="true"
form="prefix">[</mo><mtable><mtr><mtd><mrow><mi>r</mi><mi>r</mi><mi>r</mi><mo
stretchy="false"
form="prefix">|</mo><mi>r</mi></mrow><mn>1</mn></mtd><mtd><mn>0</mn></mtd><mtd><mn>0</mn></mtd><mtd><mfrac><mn>78</mn><mn>29</mn></mfrac></mtd></mtr><mtr><mtd><mn>0</mn></mtd><mtd><mn>1</mn></mtd><mtd><mn>0</mn></mtd><mtd><mfrac><mn>64</mn><mn>87</mn></mfrac></mtd></mtr><mtr><mtd><mn>0</mn></mtd><mtd><mn>0</mn></mtd><mtd><mn>1</mn></mtd><mtd><mo>−</mo><mfrac><mn>10</mn><mn>29</mn></mfrac></mtd></mtr></mtable><mo
stretchy="true" form="postfix">]</mo></mrow></math>

So I guess I am wondering whether it is possible to tweak whatever is
producing the MathML to produce the MathML that works ;-)

On 12/11/18 9:47 AM, John MacFarlane wrote:
> 
> EPUB3 supports math encoded using MathML; however, not
> all EPUB readers can handle this.  (The ones you're
> using may be among them.)
> 
> EPUB2 doesn't handle math at all, though you could try
> with `--webtex`.
> 
> Marc Grober <marc.grober-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
> 
>>  I am running   
>> pandoc Matrices.tex -o matrices.epub -f latex -t epub3
>>
>> This produces the expected pdf with the following lines:
>> \makeatletter
>> \renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{\hskip -\arraycolsep \let\
>> @ifnextchar\new@ifnextchar \array{#1}}
>> \makeatother 
>> $$\begin{bmatrix}[rrr|r] 1 & 0 & 0 & \frac{78}{29} \\ 0 & 1 & 0 & \frac{64}{
>> 87} \\ 0 & 0 & 1 & -\frac{10}{29} \end{bmatrix}$$
>>
>>
>> [image: Screen Shot 2018-12-11 at 7.35.19 AM.png]
>>
>>
>> but not the epub using Azardi, calibre or ibooks
>>
>> [image: Screen Shot 2018-12-11 at 7.33.58 AM.png]
>> I understand this is not a Latex group, but the tex seems to be working 
>> just fine...
>>
>> or is this one of those tex flavor gotchas, where pandoc has trouble with 
>> the particular tex used?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/8bc56eec-9afe-43ff-9847-a9f3150be1d6%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d6690715-52c8-3e7e-5345-75a70d1fda35%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: pEpkey.asc --]
[-- Type: application/pgp-keys, Size: 1795 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: TexShop produces a great pdf, but pandoc has trouble with matrix converting to epub
       [not found]         ` <d6690715-52c8-3e7e-5345-75a70d1fda35-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2018-12-12  0:39           ` John MacFarlane
       [not found]             ` <yh480kd0q7h92n.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: John MacFarlane @ 2018-12-12  0:39 UTC (permalink / raw)
  To: Marc Grober, pandoc-discuss


Thanks for the clarification; I should have looked at
the pictures; I was reading this in Emacs!

At first glance, it seems that what is missing from
pandoc's output are the attributes on the mtable
element:

     <mtable columnalign="right right right right" rowspacing="4pt"
      columnspacing="1em" columnlines="none none solid">

The mathml conversion is done by texmath (jgm/texmath
on GitHub), and an issue could be opened there.

Fortunately, the fix should be quite easy. texmath
parses the LaTeX to an EArray structure which includes
the alignments. The alignments just aren't affecting
the MathML rendering.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: TexShop produces a great pdf, but pandoc has trouble with matrix converting to epub
       [not found]             ` <yh480kd0q7h92n.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2018-12-12  0:46               ` John MacFarlane
       [not found]                 ` <yh480k7egfh8s5.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: John MacFarlane @ 2018-12-12  0:46 UTC (permalink / raw)
  To: Marc Grober, pandoc-discuss


OK, this time I *did* look at the pictures.
I see what is happening.  The 'rrr|r' isn't
being parsed, because of the '|'.

So the problem is more involved than I thought
before.  Our EArray structure represents
alignments, but not column lines like the `|`.
We could easy just skip the `|`, which would
improve things -- you wouldn't get the [rrrr|r]
in the output -- but you still wouldn't get the
vertical line in the output.

I'd have to think more about how to represent
this in a way that would work for our n-way
math conversions.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: TexShop produces a great pdf, but pandoc has trouble with matrix converting to epub
       [not found]                 ` <yh480k7egfh8s5.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2018-12-12  2:41                   ` Marc Grober
       [not found]                     ` <c8269467-659b-70b0-6d25-dd5c7340018d-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Grober @ 2018-12-12  2:41 UTC (permalink / raw)
  To: John MacFarlane, pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 1904 bytes --]

LOL,  Thanks for looking...  again     :-)

I suppose one could do something along the lines of:
\begin{array}{rrrrr}1 & 0 & 0 & | & x\\0&1&0&|&b\\0&0&1&|&c \end{array}
but why do that when array and the matrix directives take r,l,c, and|, lol?

How do you do lined tables if you can't do
\begin{tabular}{|c|c|c|c|c|c|c|c|}
?

I am curious, now that I used MathJax to explore the issue, whether you
might not be able to use some of its functionality to generate the
MathML.  Of course, I suppose that presents a redundancy as well as a
limitation :-(

I suppose all my problems would be solved if TexShop output epubs.
I am not holding my breath for that.

Any way, let me know if you figure anything out.

Thanks again!

On 12/11/18 3:46 PM, John MacFarlane wrote:
> 
> OK, this time I *did* look at the pictures.
> I see what is happening.  The 'rrr|r' isn't
> being parsed, because of the '|'.
> 
> So the problem is more involved than I thought
> before.  Our EArray structure represents
> alignments, but not column lines like the `|`.
> We could easy just skip the `|`, which would
> improve things -- you wouldn't get the [rrrr|r]
> in the output -- but you still wouldn't get the
> vertical line in the output.
> 
> I'd have to think more about how to represent
> this in a way that would work for our n-way
> math conversions.
> 

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/c8269467-659b-70b0-6d25-dd5c7340018d%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: pEpkey.asc --]
[-- Type: application/pgp-keys, Size: 1795 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: TexShop produces a great pdf, but pandoc has trouble with matrix converting to epub
       [not found]                     ` <c8269467-659b-70b0-6d25-dd5c7340018d-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2018-12-12  5:42                       ` John MacFarlane
       [not found]                         ` <m2sgz3i9ma.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: John MacFarlane @ 2018-12-12  5:42 UTC (permalink / raw)
  To: Marc Grober, pandoc-discuss


I've put up an issue so this won't be forgotten.
https://github.com/jgm/texmath/issues/127


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: TexShop produces a great pdf, but pandoc has trouble with matrix converting to epub
       [not found]                         ` <m2sgz3i9ma.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2018-12-13  0:32                           ` Marc Grober
  0 siblings, 0 replies; 8+ messages in thread
From: Marc Grober @ 2018-12-13  0:32 UTC (permalink / raw)
  To: John MacFarlane, pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 1034 bytes --]

Thanks.  The issue covers all the bases.

BUT.....   give this a try:

$$
\left[\begin{array}{rrr}1&0&0\\0&1&0\\0&0&1\end{array}\right|\left\begin{array}{r}a&b&c
\end{array}\right]$$

and tell me what you think  It is a bit contrived, but as it does not
use the {rrr|r} notation, it just might work as an interim solution?

On 12/11/18 8:42 PM, John MacFarlane wrote:
> 
> I've put up an issue so this won't be forgotten.
> https://github.com/jgm/texmath/issues/127
> 

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d1fbdd94-70de-78cf-2407-167645ea00a3%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: pEpkey.asc --]
[-- Type: application/pgp-keys, Size: 1795 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-12-13  0:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-11 16:54 TexShop produces a great pdf, but pandoc has trouble with matrix converting to epub Marc Grober
     [not found] ` <8bc56eec-9afe-43ff-9847-a9f3150be1d6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2018-12-11 18:47   ` John MacFarlane
     [not found]     ` <yh480kefanj3yq.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2018-12-11 21:48       ` Marc Grober
     [not found]         ` <d6690715-52c8-3e7e-5345-75a70d1fda35-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-12-12  0:39           ` John MacFarlane
     [not found]             ` <yh480kd0q7h92n.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2018-12-12  0:46               ` John MacFarlane
     [not found]                 ` <yh480k7egfh8s5.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2018-12-12  2:41                   ` Marc Grober
     [not found]                     ` <c8269467-659b-70b0-6d25-dd5c7340018d-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-12-12  5:42                       ` John MacFarlane
     [not found]                         ` <m2sgz3i9ma.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2018-12-13  0:32                           ` Marc Grober

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).