emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Strange latex symbol behavior on html export
@ 2017-09-13  2:22 Lawrence Bottorff
  2017-09-13 13:05 ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Lawrence Bottorff @ 2017-09-13  2:22 UTC (permalink / raw)
  To: emacs-orgmode Mailinglist

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

Consider this markup:

------------
* MATHEMATICS AUXILIARY

** deriving sines and cosines

#+caption: Right triangle with two $\pi\big/4$ angles.
[[file:images/45-45-triangle.png]]

$\big/$
------------

If I remove the second $\big/$, the first latex, $\pi\big/4$, in the
caption will not properly render on export to html. Include it and both
render just fine. Without the second, the first looks like this:

Figure 1: Right triangle with two \(\pi\big/4\) angles.

Is this a bug?

LB

[-- Attachment #2: Type: text/html, Size: 763 bytes --]

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

* Re: Strange latex symbol behavior on html export
  2017-09-13  2:22 Strange latex symbol behavior on html export Lawrence Bottorff
@ 2017-09-13 13:05 ` Nicolas Goaziou
  2017-09-13 22:55   ` Nick Dokos
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2017-09-13 13:05 UTC (permalink / raw)
  To: Lawrence Bottorff; +Cc: emacs-orgmode Mailinglist

Hello,

Lawrence Bottorff <borgauf@gmail.com> writes:

> Consider this markup:
>
> ------------
> * MATHEMATICS AUXILIARY
>
> ** deriving sines and cosines
>
> #+caption: Right triangle with two $\pi\big/4$ angles.
> [[file:images/45-45-triangle.png]]
>
> $\big/$
> ------------
>
> If I remove the second $\big/$, the first latex, $\pi\big/4$, in the
> caption will not properly render on export to html. Include it and both
> render just fine. Without the second, the first looks like this:
>
> Figure 1: Right triangle with two \(\pi\big/4\) angles.
>
> Is this a bug?

If you use

  #+options: tex:dvipng

the symbol in the caption is correctly rendered. It may be a bug in Mathjax.

Regards,

-- 
Nicolas Goaziou

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

* Re: Strange latex symbol behavior on html export
  2017-09-13 13:05 ` Nicolas Goaziou
@ 2017-09-13 22:55   ` Nick Dokos
  2017-09-14  0:44     ` Lawrence Bottorff
  2017-09-14 12:48     ` Nicolas Goaziou
  0 siblings, 2 replies; 7+ messages in thread
From: Nick Dokos @ 2017-09-13 22:55 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Lawrence Bottorff <borgauf@gmail.com> writes:
>
>> Consider this markup:
>>
>> ------------
>> * MATHEMATICS AUXILIARY
>>
>> ** deriving sines and cosines
>>
>> #+caption: Right triangle with two $\pi\big/4$ angles.
>> [[file:images/45-45-triangle.png]]
>>
>> $\big/$
>> ------------
>>
>> If I remove the second $\big/$, the first latex, $\pi\big/4$, in the
>> caption will not properly render on export to html. Include it and both
>> render just fine. Without the second, the first looks like this:
>>
>> Figure 1: Right triangle with two \(\pi\big/4\) angles.
>>
>> Is this a bug?
>
> If you use
>
>   #+options: tex:dvipng
>
> the symbol in the caption is correctly rendered. It may be a bug in Mathjax.
>

I looked at the diff between html files produced with and without the $\big/$ addition.
The one without does not include any of the mathjax configuration code at all. Is that
code included conditionally perhaps when a latex construct is seen? Maybe the latex construct
in the caption does not trigger the inclusion?

-- 
Nick

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

* Re: Strange latex symbol behavior on html export
  2017-09-13 22:55   ` Nick Dokos
@ 2017-09-14  0:44     ` Lawrence Bottorff
  2017-09-14  3:37       ` Nick Dokos
  2017-09-14 12:48     ` Nicolas Goaziou
  1 sibling, 1 reply; 7+ messages in thread
From: Lawrence Bottorff @ 2017-09-14  0:44 UTC (permalink / raw)
  Cc: emacs-orgmode Mailinglist

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

#+options: tex:dvipng is not good because it turns all your latex symbol
markup into images, which are inserted into the web page as images, i.e.,
it's not doing MathJax. Also bad because they don't really fit the text
lines, either. I use

# this makes MathJax work
#+OPTIONS: tex:t

I just now found this caption weirdness because I started a new .org file
with no latex symbol markup besides in the caption. Quite bizarre that when
my file sees other latex symbols, the caption symbols then render
correctly.

BTW: What does

executing Scheme code block (square)...
=> #<void>
org-babel-script-escape: ‘org-babel-script-escape’ expects a string

mean? I'm suddenly getting this in an org file which has scheme babel code
blocks, images, and lots of latex symbol markup. It first popped up when I
tried to C-c C-c a scheme code block.






On Wed, Sep 13, 2017 at 6:55 PM, Nick Dokos <ndokos@gmail.com> wrote:

> Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>
> > Hello,
> >
> > Lawrence Bottorff <borgauf@gmail.com> writes:
> >
> >> Consider this markup:
> >>
> >> ------------
> >> * MATHEMATICS AUXILIARY
> >>
> >> ** deriving sines and cosines
> >>
> >> #+caption: Right triangle with two $\pi\big/4$ angles.
> >> [[file:images/45-45-triangle.png]]
> >>
> >> $\big/$
> >> ------------
> >>
> >> If I remove the second $\big/$, the first latex, $\pi\big/4$, in the
> >> caption will not properly render on export to html. Include it and both
> >> render just fine. Without the second, the first looks like this:
> >>
> >> Figure 1: Right triangle with two \(\pi\big/4\) angles.
> >>
> >> Is this a bug?
> >
> > If you use
> >
> >   #+options: tex:dvipng
> >
> > the symbol in the caption is correctly rendered. It may be a bug in
> Mathjax.
> >
>
> I looked at the diff between html files produced with and without the
> $\big/$ addition.
> The one without does not include any of the mathjax configuration code at
> all. Is that
> code included conditionally perhaps when a latex construct is seen? Maybe
> the latex construct
> in the caption does not trigger the inclusion?
>
> --
> Nick
>
>
>

[-- Attachment #2: Type: text/html, Size: 3158 bytes --]

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

* Re: Strange latex symbol behavior on html export
  2017-09-14  0:44     ` Lawrence Bottorff
@ 2017-09-14  3:37       ` Nick Dokos
  2017-09-14  8:14         ` Rasmus
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Dokos @ 2017-09-14  3:37 UTC (permalink / raw)
  To: emacs-orgmode

Lawrence Bottorff <borgauf@gmail.com> writes:

> ... I use
>
> # this makes MathJax work
> #+OPTIONS: tex:t
>
> I just now found this caption weirdness because I started a new .org
> file with no latex symbol markup besides in the caption. Quite
> bizarre that when my file sees other latex symbols, the caption
> symbols then render correctly. 
>

> On Wed, Sep 13, 2017 at 6:55 PM, Nick Dokos <ndokos@gmail.com> wrote:
>
>     Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>    
>     > Hello,
>     >
>     > Lawrence Bottorff <borgauf@gmail.com> writes:
>     >
>     >> Consider this markup:
>     >>
>     >> ------------
>     >> * MATHEMATICS AUXILIARY
>     >>
>     >> ** deriving sines and cosines
>     >>
>     >> #+caption: Right triangle with two $\pi\big/4$ angles.
>     >> [[file:images/45-45-triangle.png]]
>     >>
>     >> $\big/$
>     >> ------------
>     >>
>     >> If I remove the second $\big/$, the first latex, $\pi\big/4$, in the
>     >> caption will not properly render on export to html. Include it and both
>     >> render just fine. Without the second, the first looks like this:
>     >>
>     >> Figure 1: Right triangle with two \(\pi\big/4\) angles.
>     >>
>     >> Is this a bug?
>     >
>     > If you use
>     >
>     >   #+options: tex:dvipng
>     >
>     > the symbol in the caption is correctly rendered. It may be a bug in Mathjax.
>     >
>    
>     I looked at the diff between html files produced with and without the $\big/$ addition.
>     The one without does not include any of the mathjax configuration code at all. Is that
>     code included conditionally perhaps when a latex construct is seen? Maybe the latex construct
>     in the caption does not trigger the inclusion?
>    
>     --
>     Nick
>

org-html--build-mathjax-config includes the mathjax code only if

  (and (memq (plist-get info :with-latex) '(mathjax t))
       (org-element-map (plist-get info :parse-tree)
		 '(latex-fragment latex-environment) 'identity info t))

is true. So if there is latex markup in the file (other than the caption) the org-element-map
call finds it and returns non-nil, but it apparently does not look inside the caption.

-- 
Nick

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

* Re: Strange latex symbol behavior on html export
  2017-09-14  3:37       ` Nick Dokos
@ 2017-09-14  8:14         ` Rasmus
  0 siblings, 0 replies; 7+ messages in thread
From: Rasmus @ 2017-09-14  8:14 UTC (permalink / raw)
  To: emacs-orgmode

Nick Dokos <ndokos@gmail.com> writes:

> Lawrence Bottorff <borgauf@gmail.com> writes:
>
>> ... I use
>>
>> # this makes MathJax work
>> #+OPTIONS: tex:t
>>
>> I just now found this caption weirdness because I started a new .org
>> file with no latex symbol markup besides in the caption. Quite
>> bizarre that when my file sees other latex symbols, the caption
>> symbols then render correctly. 
>>
>
>> On Wed, Sep 13, 2017 at 6:55 PM, Nick Dokos <ndokos@gmail.com> wrote:
>>
>>     Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>>    
>>     > Hello,
>>     >
>>     > Lawrence Bottorff <borgauf@gmail.com> writes:
>>     >
>>     >> Consider this markup:
>>     >>
>>     >> ------------
>>     >> * MATHEMATICS AUXILIARY
>>     >>
>>     >> ** deriving sines and cosines
>>     >>
>>     >> #+caption: Right triangle with two $\pi\big/4$ angles.
>>     >> [[file:images/45-45-triangle.png]]
>>     >>
>>     >> $\big/$
>>     >> ------------
>>     >>
>>     >> If I remove the second $\big/$, the first latex, $\pi\big/4$, in the
>>     >> caption will not properly render on export to html. Include it and both
>>     >> render just fine. Without the second, the first looks like this:
>>     >>
>>     >> Figure 1: Right triangle with two \(\pi\big/4\) angles.
>>     >>
>>     >> Is this a bug?
>>     >
>>     > If you use
>>     >
>>     >   #+options: tex:dvipng
>>     >
>>     > the symbol in the caption is correctly rendered. It may be a bug in Mathjax.
>>     >
>>    
>>     I looked at the diff between html files produced with and without the $\big/$ addition.
>>     The one without does not include any of the mathjax configuration code at all. Is that
>>     code included conditionally perhaps when a latex construct is seen? Maybe the latex construct
>>     in the caption does not trigger the inclusion?
>>    
>>     --
>>     Nick
>>
>
> org-html--build-mathjax-config includes the mathjax code only if
>
>   (and (memq (plist-get info :with-latex) '(mathjax t))
>        (org-element-map (plist-get info :parse-tree)
> 		 '(latex-fragment latex-environment) 'identity info t))
>
> is true.

I guess we didn’t want to load extra JS unless it’s needed.

> So if there is latex markup in the file (other than the caption) the org-element-map
> call finds it and returns non-nil, but it apparently does not look inside the caption.

When org-element looks at something like "#+caption: a $b$" it sees a
keyword.  I don’t know if it’s possible to check explicitly whether it
contains maths.  Alternatively, we could check if :with-latex is
explicitly set in the buffer (like in ox-koma-letter) and then load it
regardless.

Rasmus

-- 
This is the kind of tedious nonsense up with which I will not put

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

* Re: Strange latex symbol behavior on html export
  2017-09-13 22:55   ` Nick Dokos
  2017-09-14  0:44     ` Lawrence Bottorff
@ 2017-09-14 12:48     ` Nicolas Goaziou
  1 sibling, 0 replies; 7+ messages in thread
From: Nicolas Goaziou @ 2017-09-14 12:48 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

Hello,

Nick Dokos <ndokos@gmail.com> writes:

> I looked at the diff between html files produced with and without the $\big/$ addition.
> The one without does not include any of the mathjax configuration code at all. Is that
> code included conditionally perhaps when a latex construct is seen? Maybe the latex construct
> in the caption does not trigger the inclusion?

Good catch!

Fixed. Thank you.

Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2017-09-14 12:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-13  2:22 Strange latex symbol behavior on html export Lawrence Bottorff
2017-09-13 13:05 ` Nicolas Goaziou
2017-09-13 22:55   ` Nick Dokos
2017-09-14  0:44     ` Lawrence Bottorff
2017-09-14  3:37       ` Nick Dokos
2017-09-14  8:14         ` Rasmus
2017-09-14 12:48     ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).