emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [odt] equation labels
@ 2011-08-23 14:36 Myles English
  2011-08-26 19:36 ` Jambunathan K
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Myles English @ 2011-08-23 14:36 UTC (permalink / raw)
  To: emacs-orgmode


Hello,

I am using the excellent org-odt, so thanks to Jambunathan K, and
everyone who has ever contributed to orgmode.

This may be quite simple so I am asking before making an minimal
example.  Does anyone know how to cause a label such as "Figure 1." in
the odt (for the resulting png), and set the caption for an equation
such as:

#+CAPTION: some caption
#+LABEL: eqn:psychrometric
\begin{equation*}
\label{eq:psychrometric}
 \capillaryPressure = ln(RH)\cdot \dens_w\frac{RT}{M_w}
\end{equation*}

?

The orgmode manual says that captions and labels are for images and
tables so unless there is a special trick I would probably try to wrap
the latex in something first, for dvipng to return the png to org, to
apply the CAPTION to, before exporting to odt.

Extra points for making it "Equation 1." instead of "Figure 1.".

Thanks,

Myles

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

* Re: [odt] equation labels
  2011-08-23 14:36 [odt] equation labels Myles English
@ 2011-08-26 19:36 ` Jambunathan K
  2011-08-27 22:02 ` Jambunathan K
  2011-09-17 19:48 ` Jambunathan K
  2 siblings, 0 replies; 21+ messages in thread
From: Jambunathan K @ 2011-08-26 19:36 UTC (permalink / raw)
  To: emacs-orgmode


Hello Myles

> \begin{equation*}
> \label{eq:psychrometric}
>  \capillaryPressure = ln(RH)\cdot \dens_w\frac{RT}{M_w}
> \end{equation*}

dvipng refuses to produce png tex snippet above. I am not at all
 familiar with latex. I am not sure what is wrong.

If you have a good number of equations in your orgfile can you share it
with me? I can use it as a real-life example and cook up a preliminary
latex->mathml support using mathtoweb.

Do you have any quick opinions on mathtoweb? See my earlier post
http://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01755.html

Regarding your captions request, I will cook up something. But I would
like to fold it as part of latex->mathml work. Let's see.

Jambunathan K.

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

* Re: [odt] equation labels
  2011-08-23 14:36 [odt] equation labels Myles English
  2011-08-26 19:36 ` Jambunathan K
@ 2011-08-27 22:02 ` Jambunathan K
  2011-08-31 11:09   ` Myles English
  2011-09-17 19:48 ` Jambunathan K
  2 siblings, 1 reply; 21+ messages in thread
From: Jambunathan K @ 2011-08-27 22:02 UTC (permalink / raw)
  To: Myles English; +Cc: emacs-orgmode

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


Myles

> Does anyone know how to cause a label such as "Figure 1." in the odt
> (for the resulting png), and set the caption for an equation such as:
>
> #+CAPTION: some caption
> #+LABEL: eqn:psychrometric
> \begin{equation*}
> \label{eq:psychrometric}
>  \capillaryPressure = ln(RH)\cdot \dens_w\frac{RT}{M_w}
> \end{equation*}
>
> ?
>
> The orgmode manual says that captions and labels are for images and
> tables so unless there is a special trick I would probably try to wrap
> the latex in something first, for dvipng to return the png to org, to
> apply the CAPTION to, before exporting to odt.
>
> Extra points for making it "Equation 1." instead of "Figure 1.".

I have added support for honoring captions, label and attributes for
images that are dervied from latex fragments. Checkout the git repo and
let me know if there are any rough edges that need to be ironed out.

Note that the odt exporter treats Labels and their references in a
special way.

For example, if the label is defined as follows,

#+LABEL: Equation:1

Equation is considered as a "Category" [1] and "1" is considered as
sequence number. So this "category:seq-no" is the recommended form of
labels for odt export. Note that the seq-no found in Org file need not
be sequential. The odt exporter will faithfully reproduce the seqnos as
seen Org file to the odt file. You can auto-generate the "right" seqnos
by using Tools->Update->Update All.

If you are averse to launching the gui for updating of indices you can
do a odt->odt (yes, odt->odt) conversion for sanitizing of indices [2].

It is also worth noting that the attached file uses the as yet
undocumented 

#+ATTR_ODT: (:scale 2) 

to scale the image to twice the original size.

Jambunathan K.

> Thanks,
>
> Myles
>
>

Footnotes: 

[1]  Other "Categories" could be Illustration, Table, Text etc.
[2]  I have never used unoconv myself. But the source code does update
indices of the input document before further conversion.

-- 

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: eqns.org --]
[-- Type: text/x-org, Size: 712 bytes --]

#+TITLE:     eqns.org
#+AUTHOR:    Jambunathan K
#+EMAIL:     kjambunathan@gmail.com
#+DATE:      2011-08-26 Fri
#+DESCRIPTION:
#+KEYWORDS:
#+LANGUAGE:  en
#+OPTIONS:   H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS:   TeX:t LaTeX:dvipng skip:nil d:nil todo:t pri:nil tags:not-in-toc

#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
#+LINK_UP:   
#+LINK_HOME: 
#+XSLT:

* Equations

  There is a equation down below.

#+CAPTION: Kinetic Energy
#+LABEL: Equation:1
#+ATTR_ODT: (:scale 2)

  \begin{equation*}
  e = \frac{1}{2}mv^2
  \end{equation*}

#+CAPTION: Kinetic Energy
#+LABEL: Equation:2
#+ATTR_ODT: (:scale 0.5)

  \begin{equation*}
  e = \frac{1}{2}mv^2
  \end{equation*}

[-- Attachment #3: eqns.odt --]
[-- Type: application/vnd.oasis.opendocument.text, Size: 9498 bytes --]

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

* Re: [odt] equation labels
  2011-08-27 22:02 ` Jambunathan K
@ 2011-08-31 11:09   ` Myles English
  2011-08-31 11:37     ` suvayu ali
                       ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Myles English @ 2011-08-31 11:09 UTC (permalink / raw)
  To: Jambunathan K; +Cc: emacs-orgmode


Jambunathan,

>> On Sun, 28 Aug 2011 03:32:10 +0530, Jambunathan K said:

  > Myles

  >> Does anyone know how to cause a label such as "Figure 1." in the
  >> odt (for the resulting png), and set the caption for an equation
  >> such as:
  >> 
  >> #+CAPTION: some caption #+LABEL: eqn:psychrometric
  >> \begin{equation*} \label{eq:psychrometric} \capillaryPressure =
  >> ln(RH)\cdot \dens_w\frac{RT}{M_w} \end{equation*}

Sorry for the red herring: the equation above would never have worked
without mystyle.sty whose content includes:

\newcommand{\pressure}{p}
\newcommand{\capillaryPressure}{{\pressure_{c}}}
\newcommand{\dens_w}{\rho_w}

and is included by:

#+LATEX_HEADER: \usepackage{/home/myles/path/to/report/mystyle}

  > I have added support for honoring captions, label and attributes for
  > images that are dervied from latex fragments. Checkout the git repo
  > and let me know if there are any rough edges that need to be ironed
  > out.

Thank you!  I have just got around to trying this out and it works
great.  The only issue now is that the resolution of the pngs is low and
looks terrible.  I vaguely remember changing it deep in my latex
installation somewhere.

  > Note that the odt exporter treats Labels and their references in a
  > special way.

  > For example, if the label is defined as follows,

  > #+LABEL: Equation:1

  > Equation is considered as a "Category" [1] and "1" is considered as
  > sequence number. So this "category:seq-no" is the recommended form
  > of labels for odt export. Note that the seq-no found in Org file
  > need not be sequential. The odt exporter will faithfully reproduce
  > the seqnos as seen Org file to the odt file. You can auto-generate
  > the "right" seqnos by using Tools->Update->Update All.

  > If you are averse to launching the gui for updating of indices you
  > can do a odt->odt (yes, odt->odt) conversion for sanitizing of
  > indices [2].

  > It is also worth noting that the attached file uses the as yet
  > undocumented

  > #+ATTR_ODT: (:scale 2)

  > to scale the image to twice the original size.

  > Jambunathan K.

I your previous post you asked for my org file but I think that it is
superseded by your attachment?  When I have finished this report I am
working on I'll cut it down and offer it as an example if you like.

Myles

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

* Re: [odt] equation labels
  2011-08-31 11:09   ` Myles English
@ 2011-08-31 11:37     ` suvayu ali
  2011-08-31 11:50     ` Myles English
  2011-08-31 14:07     ` Jambunathan K
  2 siblings, 0 replies; 21+ messages in thread
From: suvayu ali @ 2011-08-31 11:37 UTC (permalink / raw)
  To: Myles English, emacs-orgmode; +Cc: Jambunathan K

On Wed, Aug 31, 2011 at 1:09 PM, Myles English <mylesenglish@gmail.com> wrote:
> I your previous post you asked for my org file but I think that it is
> superseded by your attachment?  When I have finished this report I am
> working on I'll cut it down and offer it as an example if you like.

Examples like these are always a welcome addition to Worg. :)

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: [odt] equation labels
  2011-08-31 11:09   ` Myles English
  2011-08-31 11:37     ` suvayu ali
@ 2011-08-31 11:50     ` Myles English
  2011-08-31 13:52       ` Jambunathan K
  2011-08-31 14:07     ` Jambunathan K
  2 siblings, 1 reply; 21+ messages in thread
From: Myles English @ 2011-08-31 11:50 UTC (permalink / raw)
  To: emacs-orgmode



>> On Wed, 31 Aug 2011 12:09:58 +0100, Myles English said:

  >> I have added support for honoring captions, label and attributes
  >> for images that are dervied from latex fragments. Checkout the git
  >> repo and let me know if there are any rough edges that need to be
  >> ironed out.

  > Thank you!  I have just got around to trying this out and it works
  > great.  The only issue now is that the resolution of the pngs is low
  > and looks terrible.  I vaguely remember changing it deep in my latex
  > installation somewhere.

Actually there is an old (2006) thread including a patch about a file
option to change the resolution:

http://lists.gnu.org/archive/html/emacs-orgmode/2006-09/msg00010.html

But I don't think it was applied and I am not sure how it would fit in
the current scheme.  Can anyone advise?

Myles

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

* Re: [odt] equation labels
  2011-08-31 11:50     ` Myles English
@ 2011-08-31 13:52       ` Jambunathan K
  0 siblings, 0 replies; 21+ messages in thread
From: Jambunathan K @ 2011-08-31 13:52 UTC (permalink / raw)
  To: Myles English; +Cc: emacs-orgmode

Myles English <mylesenglish@gmail.com> writes:

>>> On Wed, 31 Aug 2011 12:09:58 +0100, Myles English said:
>
>   >> I have added support for honoring captions, label and attributes
>   >> for images that are dervied from latex fragments. Checkout the git
>   >> repo and let me know if there are any rough edges that need to be
>   >> ironed out.
>
>   > Thank you!  I have just got around to trying this out and it works
>   > great.  The only issue now is that the resolution of the pngs is low
>   > and looks terrible.  I vaguely remember changing it deep in my latex
>   > installation somewhere.
>
> Actually there is an old (2006) thread including a patch about a file
> option to change the resolution:
>
> http://lists.gnu.org/archive/html/emacs-orgmode/2006-09/msg00010.html

INCREASING the `:html-scale' scale property in
`org-format-latex-options' will INCREASE the `-D' option by same factor.

I believe the above setting together with a "suitable" value of
#+ATTR_ODT: (:scale xxx) will achieve the required balance.

If you have lots of equations then applying #+ATTR_ODT option to each of
the images is a bit cumbersome. In that case you can tweak
`org-export-odt-pixels-per-inch' (The default value of this variable is
same as `display-pixels-per-inch' variable of Emacs session). HALVING
this variable will DOUBLE the size of all images uniformly.

Note for posterity:
1. ODT expects that the image size be specified in cms or inches. I
   believe image files have no "physical" dimensions associated with
   them but only pixel size. Mapping from pixels to cms or inches is
   again determined by display properties (ie, the same image will
   appear in different physical dimensions on different monitors.)

2. On my Netbook, MS Paint uses a pixels-per-inch of 96.0 while Emacs'
   display-pixels-per-inch reports a value of 72.0

Image sizes are a grey area to me. If there is an expert out there
willing to educate me I am all ears.

Jambunathan K.

> But I don't think it was applied and I am not sure how it would fit in
> the current scheme.  Can anyone advise?
>
> Myles
>
>
>

-- 

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

* Re: [odt] equation labels
  2011-08-31 11:09   ` Myles English
  2011-08-31 11:37     ` suvayu ali
  2011-08-31 11:50     ` Myles English
@ 2011-08-31 14:07     ` Jambunathan K
  2 siblings, 0 replies; 21+ messages in thread
From: Jambunathan K @ 2011-08-31 14:07 UTC (permalink / raw)
  To: Myles English; +Cc: emacs-orgmode


Myles

> I your previous post you asked for my org file but I think that it is
> superseded by your attachment?  

The example I used is from my own unit test file.

> When I have finished this report I am working on I'll cut it down and
> offer it as an example if you like.

Sure, I would very much want to receive a copy of your file with
equations. I will be adding support for LaTeX->MathML in another few
days time and I need some real life equations to assess the suitability
of mathtoweb converter and prototype my changes [1].

Using mathml for equations will also ensure that the equations are first
class citizens in the document and "scale" with the document settings.

Jambunathan K.

Footnotes: 

[1] Bonus points if your file has all manners of equations - equations
that flow with the text AND equations that are rendered as
paragraph. ODT exporter might have to tweak the "anchoring - character?
or paragraph?" properties of the resulting embedded object depending on
what manner of equation it is.

-- 

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

* Re: [odt] equation labels
  2011-08-23 14:36 [odt] equation labels Myles English
  2011-08-26 19:36 ` Jambunathan K
  2011-08-27 22:02 ` Jambunathan K
@ 2011-09-17 19:48 ` Jambunathan K
  2 siblings, 0 replies; 21+ messages in thread
From: Jambunathan K @ 2011-09-17 19:48 UTC (permalink / raw)
  To: Myles English; +Cc: emacs-orgmode


Myles 

Subsequent to our last interaction I added support LaTeX to MathML
conversion[1] and also enhanced the support for how the equations are
numbered.

You may want to look at all three posts in this thread.
http://www.mail-archive.com/emacs-orgmode@gnu.org/msg46437.html

Any feedback or comment is welcome. 

TIA,
Jambunathan K.

Footnotes: 
[1]  The patch is pending and has not hit the git repo yet

-- 

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

* [odt] equation labels
@ 2011-10-28  1:23 Myles English
  2011-10-30 22:11 ` Jambunathan K
  0 siblings, 1 reply; 21+ messages in thread
From: Myles English @ 2011-10-28  1:23 UTC (permalink / raw)
  To: emacs-orgmode


Hello {Jambunathan},

I have found that Equations become labelled as Figures in the version I
am using:

emacs 23.3.1
org-mode from git commit 71f1c1be (Oct 26)

(?I'm not sure if it is the most recent version of contrib/org-odt as
the README.org says "This release is is as good as org-20110613" etc)

The test equations in latex-mathml.org in this message:

http://lists.gnu.org/archive/html/emacs-orgmode/2011-09/msg00198.html

are labelled as "Equation" in the odt files but when I export it fresh I get
"Figure".

Thank you for the recent MathML stuff by the way.

Myles

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

* Re: [odt] equation labels
  2011-10-28  1:23 Myles English
@ 2011-10-30 22:11 ` Jambunathan K
  2011-10-31 11:54   ` Myles English
  0 siblings, 1 reply; 21+ messages in thread
From: Jambunathan K @ 2011-10-30 22:11 UTC (permalink / raw)
  To: emacs-orgmode

Myles English <mylesenglish@gmail.com> writes:

> Hello {Jambunathan},
>
> I have found that Equations become labelled as Figures in the version I
> am using:
>
> emacs 23.3.1
> org-mode from git commit 71f1c1be (Oct 26)
> The test equations in latex-mathml.org in this message:
>
> http://lists.gnu.org/archive/html/emacs-orgmode/2011-09/msg00198.html
>
> are labelled as "Equation" in the odt files but when I export it fresh I get
> "Figure".

This was a regression. I pushed a fix few moments ago. Could you please
pull again?

> (?I'm not sure if it is the most recent version of contrib/org-odt as
> the README.org says "This release is is as good as org-20110613" etc)

I have not updated README.org for a while and please ignore whatever it
claims.  You are using the right version of odt. So no worries.

> Thank you for the recent MathML stuff by the way.
>
> Myles
>
>

-- 

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

* Re: [odt] equation labels
  2011-10-30 22:11 ` Jambunathan K
@ 2011-10-31 11:54   ` Myles English
  2011-11-01 11:17     ` Myles English
  2011-11-01 19:39     ` Jambunathan K
  0 siblings, 2 replies; 21+ messages in thread
From: Myles English @ 2011-10-31 11:54 UTC (permalink / raw)
  To: emacs-orgmode


>> On Mon, 31 Oct 2011 03:41:18 +0530, Jambunathan K said:

  > Myles English <mylesenglish@gmail.com> writes:
  >> I have found that Equations become labelled as Figures in the
  >> version I am using:
  >> 
  >> emacs 23.3.1 org-mode from git commit 71f1c1be (Oct 26) The test
  >> equations in latex-mathml.org in this message:
  >> 
  >> http://lists.gnu.org/archive/html/emacs-orgmode/2011-09/msg00198.html
  >> 
  >> are labelled as "Equation" in the odt files but when I export it
  >> fresh I get "Figure".

  > This was a regression. I pushed a fix few moments ago. Could you
  > please pull again?

Thanks for the push, there are three things I notice now:

1) my document won't open and causes libreoffice to crash! I get:
   "terminate called after throwing an instance of
     what():  vector::_M_default_append" on the command line

2) the first equation in latex-mathml.org is not numbered, I would
   expect this if it was using a begin{equation*} environment but not a
   begin{equation}.

3) the second equation looks a bit like this:

   x=root(b)               (1)
   Radicals

   but I would have expected something like:

   x=root(b)
   Equation 1.: Radicals

Is there a new variable that I need to set to get (e.g.) "Equation 1."?

Just to be explicit, the test file latex-mathml.org I am referring to
contains:

#+TITLE:     latex-mathml.org
#+AUTHOR:    Jambunathan K
#+EMAIL:     address@hidden
#+DATE:      2011-09-09 Fri
#+DESCRIPTION:
#+KEYWORDS:
#+LANGUAGE:  en
#+OPTIONS:   H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc

#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
#+LINK_UP:   
#+LINK_HOME: 
#+XSLT:

* LaTeX Fragments

** LaTeX Fragment1
#   See org-format-latex-options

    There is a equation down below.

   \begin{equation}
     e = \frac{1}{2}mv^2
   \end{equation}

** LaTeX Fragment2

#+CAPTION: Radicals
#+LABEL: Equation:1
   \begin{equation}
   x=\sqrt{b}
   \end{equation}

   If $a^2=b$ and \( b=2 \), then the solution must be either $$
   a=+\sqrt{2} $$ or \[ a=-\sqrt{2} \].


Myles

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

* Re: [odt] equation labels
  2011-10-31 11:54   ` Myles English
@ 2011-11-01 11:17     ` Myles English
  2011-11-01 19:39     ` Jambunathan K
  1 sibling, 0 replies; 21+ messages in thread
From: Myles English @ 2011-11-01 11:17 UTC (permalink / raw)
  To: emacs-orgmode

>> On Mon, 31 Oct 2011 11:54:35 +0000, Myles English said:

>> On Mon, 31 Oct 2011 03:41:18 +0530, Jambunathan K said:

  >> Myles English <mylesenglish@gmail.com> writes:
  >>> I have found that Equations become labelled as Figures in the
  >>> version I am using:
  >>> 
  >>> emacs 23.3.1 org-mode from git commit 71f1c1be (Oct 26) The test
  >>> equations in latex-mathml.org in this message:
  >>> 
  >>> http://lists.gnu.org/archive/html/emacs-orgmode/2011-09/msg00198.html
  >>> 
  >>> are labelled as "Equation" in the odt files but when I export it
  >>> fresh I get "Figure".

  >> This was a regression. I pushed a fix few moments ago. Could you
  >> please pull again?

  > Thanks for the push, there are three things I notice now:

  > 1) my document won't open and causes libreoffice to crash! I get:
  > "terminate called after throwing an instance of what():
  > vector::_M_default_append" on the command line

  > 2) the first equation in latex-mathml.org is not numbered, I would
  > expect this if it was using a begin{equation*} environment but not a
  > begin{equation}.

  > 3) the second equation looks a bit like this:

  >    x=root(b) (1) Radicals

  >    but I would have expected something like:

  >    x=root(b) Equation 1.: Radicals

Alright, points 2 and 3 are cleared up by me understanding that the
asterisk in \begin{equation*} has no visible effect, and that instead of
having "Equation 1.:" in the caption below the formula, there is a "(1)"
on the RHS.

Point 1 is entirely my own problem.

Myles

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

* Re: [odt] equation labels
  2011-10-31 11:54   ` Myles English
  2011-11-01 11:17     ` Myles English
@ 2011-11-01 19:39     ` Jambunathan K
  2011-11-01 19:49       ` Jambunathan K
  2011-11-02 13:18       ` Myles English
  1 sibling, 2 replies; 21+ messages in thread
From: Jambunathan K @ 2011-11-01 19:39 UTC (permalink / raw)
  To: emacs-orgmode


Myles

(I have read the followup post to this set of questions)

Myles English <mylesenglish@gmail.com> writes:
>>> On Mon, 31 Oct 2011 03:41:18 +0530, Jambunathan K said:
>
>   > Myles English <mylesenglish@gmail.com> writes:
>   >> I have found that Equations become labelled as Figures in the
>   >> version I am using:
>   >> 
>   >> emacs 23.3.1 org-mode from git commit 71f1c1be (Oct 26) The test
>   >> equations in latex-mathml.org in this message:
>   >> 
>   >> http://lists.gnu.org/archive/html/emacs-orgmode/2011-09/msg00198.html
>   >> 
>   >> are labelled as "Equation" in the odt files but when I export it
>   >> fresh I get "Figure".
>
>   > This was a regression. I pushed a fix few moments ago. Could you
>   > please pull again?
>
> Thanks for the push, there are three things I notice now:
>
> 1) my document won't open and causes libreoffice to crash! I get:
>    "terminate called after throwing an instance of
>      what():  vector::_M_default_append" on the command line

1. You are using custom styles for your latex fragment
2. latex-to-mathml converter - as it stands today - assumes the latex
   fragment is completed in and of itself and doesn't honor the style
   settings.

Putting 1 and 2 together, I am assuming that the XML created by the ODT
emitter contains garbage which is causing LibreOffice to be confused. In
my observation, ill-formed XML triggers "file is corrupt and should I
repair the file?" from LibreOffice. A crash seems strange to me.

1. http://article.gmane.org/gmane.emacs.orgmode/48714
   - Above link has my note on -ncf option to mathtoweb

2. http://orgmode.org/worg/org-faq.html
   - Above link has a note on how to debug corrupt odt files.
     (Hint: search for corrupt)

> 2) the first equation in latex-mathml.org is not numbered, I would
>    expect this if it was using a begin{equation*} environment but not a
>    begin{equation}.

Currently the odt exporter doesn't peek in to the latex fragment and
infer what manner of equation it is. This is something that I could take
up ...

,----
| (defvar org-latex-regexps
|   '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t)
|     ;; ("$" "\\([ 	(]\\|^\\)\\(\\(\\([$]\\)\\([^ 	\r\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ 	\r\n,.$]\\)\\4\\)\\)\\([ 	.,?;:'\")]\\|$\\)" 2 nil)
|     ;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p
|     ("$1" "\\([^$]\\|^\\)\\(\\$[^ 	\r\n,;.$]\\$\\)\\([- 	.,?;:'\")\000]\\|$\\)" 2 nil)
|     ("$" "\\([^$]\\|^\\)\\(\\(\\$\\([^ 	\r\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ 	\r\n,.$]\\)\\$\\)\\)\\([- 	.,?;:'\")\000]\\|$\\)" 2 nil)
|     ("\\(" "\\\\([^\000]*?\\\\)" 0 nil)
|     ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 nil)
|     ("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil))
|   "Regular expressions for matching embedded LaTeX.")
`----


> 3) the second equation looks a bit like this:
>
>    x=root(b)               (1)
>    Radicals
>
>    but I would have expected something like:
>
>    x=root(b)
>    Equation 1.: Radicals
>
> Is there a new variable that I need to set to get (e.g.) "Equation
> 1."?

Being a non-latex user, I am not familiar with what the usual practice
is. If the latter option is how captioned equations are normally typeset
I can take it up. Can you confirm that the expectations above are *not*
your own but that of *any* user?

> Just to be explicit, the test file latex-mathml.org I am referring to
> contains:
>
> #+TITLE:     latex-mathml.org
> #+AUTHOR:    Jambunathan K
> #+EMAIL:     address@hidden
> #+DATE:      2011-09-09 Fri
> #+DESCRIPTION:
> #+KEYWORDS:
> #+LANGUAGE:  en
> #+OPTIONS:   H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
> #+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
>
> #+EXPORT_SELECT_TAGS: export
> #+EXPORT_EXCLUDE_TAGS: noexport
> #+LINK_UP:   
> #+LINK_HOME: 
> #+XSLT:
>
> * LaTeX Fragments
>
> ** LaTeX Fragment1
> #   See org-format-latex-options
>
>     There is a equation down below.
>
>    \begin{equation}
>      e = \frac{1}{2}mv^2
>    \end{equation}
>
> ** LaTeX Fragment2
>
> #+CAPTION: Radicals
> #+LABEL: Equation:1
>    \begin{equation}
>    x=\sqrt{b}
>    \end{equation}
>
>    If $a^2=b$ and \( b=2 \), then the solution must be either $$
>    a=+\sqrt{2} $$ or \[ a=-\sqrt{2} \].
>
>
> Myles
>
>

-- 

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

* Re: [odt] equation labels
  2011-11-01 19:39     ` Jambunathan K
@ 2011-11-01 19:49       ` Jambunathan K
  2011-11-02 13:18       ` Myles English
  1 sibling, 0 replies; 21+ messages in thread
From: Jambunathan K @ 2011-11-01 19:49 UTC (permalink / raw)
  To: emacs-orgmode


>> 2) the first equation in latex-mathml.org is not numbered, I would
>>    expect this if it was using a begin{equation*} environment but not a
>>    begin{equation}.
>
> Currently the odt exporter doesn't peek in to the latex fragment and
> infer what manner of equation it is. This is something that I could take
> up ...

As thing stand today, to produce a numbered equation just attach
#+LABEL: to it. This is how odt exporter determines when a formula is
numbered or not.
-- 

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

* Re: [odt] equation labels
  2011-11-01 19:39     ` Jambunathan K
  2011-11-01 19:49       ` Jambunathan K
@ 2011-11-02 13:18       ` Myles English
       [not found]         ` <mylesenglish@gmail.com>
  1 sibling, 1 reply; 21+ messages in thread
From: Myles English @ 2011-11-02 13:18 UTC (permalink / raw)
  To: emacs-orgmode


Jambunathan,

>> On Wed, 02 Nov 2011 01:09:41 +0530, Jambunathan K said:

  > Myles

  > (I have read the followup post to this set of questions)

  > Myles English <mylesenglish@gmail.com> writes:
  >>>> On Mon, 31 Oct 2011 03:41:18 +0530, Jambunathan K said:
  >> 
  >> > Myles English <mylesenglish@gmail.com> writes: >> I have found
  >> that Equations become labelled as Figures in the >> version I am
  >> using:
  >> >> 
  >> >> emacs 23.3.1 org-mode from git commit 71f1c1be (Oct 26) The test
  >> >> equations in latex-mathml.org in this message:
  >> >> 
  >> >>
  >> http://lists.gnu.org/archive/html/emacs-orgmode/2011-09/msg00198.html
  >> >> 
  >> >> are labelled as "Equation" in the odt files but when I export it
  >> >> fresh I get "Figure".
  >> 
  >> > This was a regression. I pushed a fix few moments ago. Could you
  >> > please pull again?
  >> 
  >> Thanks for the push, there are three things I notice now:
  >> 
  >> 1) my document won't open and causes libreoffice to crash! I get:
  >> "terminate called after throwing an instance of what():
  >> vector::_M_default_append" on the command line

  > 1. You are using custom styles for your latex fragment
  > 2. latex-to-mathml converter - as it stands today - assumes the
  > latex fragment is completed in and of itself and doesn't honor the
  > style settings.

  > Putting 1 and 2 together, I am assuming that the XML created by the
  > ODT emitter contains garbage which is causing LibreOffice to be
  > confused. In my observation, ill-formed XML triggers "file is
  > corrupt and should I repair the file?" from LibreOffice. A crash
  > seems strange to me.

There is (git from a couple of days ago) a problem with referring to
equations containing an underscore in the label, I am fairly sure it was
allowed before, e.g.:

--8<---------------cut here---------------start------------->8---
#+LABEL: Equation:new_eq
     \begin{equation}
     x=\sqrt{b}
     \end{equation}

Referring to an equation with an underscore: \ref{Equation:new_eq}
--8<---------------cut here---------------end--------------->8---

I get a libreoffice popup:

"Read Error. Format error discovered in the file in sub-document
content.xmlat 2236,92(row,col)."

I think it was many of these errors that caused the crash.

  > 1. http://article.gmane.org/gmane.emacs.orgmode/48714 - Above link
  > has my note on -ncf option to mathtoweb

  > 2. http://orgmode.org/worg/org-faq.html - Above link has a note on
  > how to debug corrupt odt files.  (Hint: search for corrupt)

  >> 2) the first equation in latex-mathml.org is not numbered, I would
  >> expect this if it was using a begin{equation*} environment but not
  >> a begin{equation}.

  > Currently the odt exporter doesn't peek in to the latex fragment and
  > infer what manner of equation it is. This is something that I could
  > take up ...

  > ,---- | (defvar org-latex-regexps | '(("begin" "^[
  > \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t)
  > | ;; ("$" "\\([ (]\\|^\\)\\(\\(\\([$]\\)\\([^
  > \r\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \r\n,.$]\\)\\4\\)\\)\\([
  > .,?;:'\")]\\|$\\)" 2 nil) | ;; \000 in the following regex is needed
  > for org-inside-LaTeX-fragment-p | ("$1" "\\([^$]\\|^\\)\\(\\$[^
  > \r\n,;.$]\\$\\)\\([- .,?;:'\")\000]\\|$\\)" 2 nil) | ("$"
  > "\\([^$]\\|^\\)\\(\\(\\$\\([^
  > \r\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^
  > \r\n,.$]\\)\\$\\)\\)\\([- .,?;:'\")\000]\\|$\\)" 2 nil) | ("\\("
  > "\\\\([^\000]*?\\\\)" 0 nil) | ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0
  > nil) | ("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil)) | "Regular expressions
  > for matching embedded LaTeX.")  `----

Crikey!  That's quite a regexp.  I think the only consideration is
whether you want it to be consistent with pdf export.  Taking
consistency to an extreme could lead to a new #+begin_equation block
(<-- I haven't thought this through at all).  Having said that I am
happy with the way it works at the moment.

  >> 3) the second equation looks a bit like this:
  >> 
  >> x=root(b) (1) Radicals
  >> 
  >> but I would have expected something like:
  >> 
  >> x=root(b) Equation 1.: Radicals
  >> 
  >> Is there a new variable that I need to set to get (e.g.) "Equation
  >> 1."?

  > Being a non-latex user, I am not familiar with what the usual
  > practice is. If the latter option is how captioned equations are
  > normally typeset I can take it up. Can you confirm that the
  > expectations above are *not* your own but that of *any* user?

Actually I have changed my mind, it does look better like that, it is
just that is was different behaviour to what happened before.

Myles

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

* Re: [odt] equation labels
       [not found]         ` <mylesenglish@gmail.com>
@ 2011-11-02 13:38           ` Nick Dokos
  2011-11-02 14:49             ` Myles English
  2011-11-02 14:52           ` Nick Dokos
  1 sibling, 1 reply; 21+ messages in thread
From: Nick Dokos @ 2011-11-02 13:38 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: nicholas.dokos

Myles English <mylesenglish@gmail.com> wrote:

> 
> There is (git from a couple of days ago) a problem with referring to
> equations containing an underscore in the label, I am fairly sure it was
> allowed before, e.g.:
> 
> #+LABEL: Equation:new_eq
>      \begin{equation}
>      x=\sqrt{b}
>      \end{equation}
> 
> Referring to an equation with an underscore: \ref{Equation:new_eq}
> 
> I get a libreoffice popup:
> 
> "Read Error. Format error discovered in the file in sub-document
> content.xmlat 2236,92(row,col)."
> 

I can reproduce that and it may be a consequence of a change that
I introduced at the top level export engine about six months ago.
Let me take a look.

Nick

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

* Re: [odt] equation labels
  2011-11-02 13:38           ` Nick Dokos
@ 2011-11-02 14:49             ` Myles English
  0 siblings, 0 replies; 21+ messages in thread
From: Myles English @ 2011-11-02 14:49 UTC (permalink / raw)
  To: emacs-orgmode


Nick,

>> On Wed, 02 Nov 2011 09:38:20 -0400, Nick Dokos said:

  > Myles English <mylesenglish@gmail.com> wrote:
  >> 
  >> There is (git from a couple of days ago) a problem with referring
  >> to equations containing an underscore in the label, I am fairly
  >> sure it was allowed before, e.g.:
  >> 
  >> #+LABEL: Equation:new_eq \begin{equation} x=\sqrt{b} \end{equation}
  >> 
  >> Referring to an equation with an underscore: \ref{Equation:new_eq}
  >> 
  >> I get a libreoffice popup:
  >> 
  >> "Read Error. Format error discovered in the file in sub-document
  >> content.xmlat 2236,92(row,col)."
  >> 

  > I can reproduce that and it may be a consequence of a change that I
  > introduced at the top level export engine about six months ago.  Let
  > me take a look.

  > Nick

I may be mistaken but I think it became broken more recently, circa 7th
Oct.

Myles

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

* Re: [odt] equation labels
       [not found]         ` <mylesenglish@gmail.com>
  2011-11-02 13:38           ` Nick Dokos
@ 2011-11-02 14:52           ` Nick Dokos
  2011-11-02 18:21             ` Jambunathan K
  1 sibling, 1 reply; 21+ messages in thread
From: Nick Dokos @ 2011-11-02 14:52 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: nicholas.dokos

Myles English <mylesenglish@gmail.com> wrote:

> 
> Nick,
> 
> >> On Wed, 02 Nov 2011 09:38:20 -0400, Nick Dokos said:
> 
>   > Myles English <mylesenglish@gmail.com> wrote:
>   >> 
>   >> There is (git from a couple of days ago) a problem with referring
>   >> to equations containing an underscore in the label, I am fairly
>   >> sure it was allowed before, e.g.:
>   >> 
>   >> #+LABEL: Equation:new_eq \begin{equation} x=\sqrt{b} \end{equation}
>   >> 
>   >> Referring to an equation with an underscore: \ref{Equation:new_eq}
>   >> 
>   >> I get a libreoffice popup:
>   >> 
>   >> "Read Error. Format error discovered in the file in sub-document
>   >> content.xmlat 2236,92(row,col)."
>   >> 
> 
>   > I can reproduce that and it may be a consequence of a change that I
>   > introduced at the top level export engine about six months ago.  Let
>   > me take a look.
> 
>   > Nick
> 
> I may be mistaken but I think it became broken more recently, circa 7th
> Oct.
> 

OK - phew (although I may not be out of the woods yet). It seems that the
underscore in the link is interpreted as a subscript:

,----
| ...
| Referring to an equation with an underscore: <text:sequence-ref text:ref-name="Equation:new<text:span text:style-name="OrgSubscript">eq</text:span>"/>
`----

Thanks,
Nick

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

* Re: [odt] equation labels
  2011-11-02 14:52           ` Nick Dokos
@ 2011-11-02 18:21             ` Jambunathan K
  2011-11-02 21:33               ` Myles English
  0 siblings, 1 reply; 21+ messages in thread
From: Jambunathan K @ 2011-11-02 18:21 UTC (permalink / raw)
  To: Myles English; +Cc: nicholas.dokos, emacs-orgmode


>>   >> There is (git from a couple of days ago) a problem with referring
>>   >> to equations containing an underscore in the label, I am fairly
>>   >> sure it was allowed before, e.g.:
>>   >> 
>>   >> #+LABEL: Equation:new_eq \begin{equation} x=\sqrt{b} \end{equation}
>>   >> 
>>   >> Referring to an equation with an underscore: \ref{Equation:new_eq}
>>   >> 
>>   >> I get a libreoffice popup:
>>   >> 
>>   >> "Read Error. Format error discovered in the file in sub-document
>>   >> content.xmlat 2236,92(row,col)."
>>   >> 
> OK - phew (although I may not be out of the woods yet). It seems that the
> underscore in the link is interpreted as a subscript:
>
> ,----
> | ...
> | Referring to an equation with an underscore: <text:sequence-ref
> | text:ref-name="Equation:new<text:span
> | text:style-name="OrgSubscript">eq</text:span>"/>
> `----

Nick, Thanks for debugging this and isolating the root cause.
Myles, I have pushed a fix few minutes ago. Hope things are OK now.

-- 

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

* Re: [odt] equation labels
  2011-11-02 18:21             ` Jambunathan K
@ 2011-11-02 21:33               ` Myles English
  0 siblings, 0 replies; 21+ messages in thread
From: Myles English @ 2011-11-02 21:33 UTC (permalink / raw)
  To: emacs-orgmode

>> On Wed, 02 Nov 2011 23:51:31 +0530, Jambunathan K said:

>>   >> There is (git from a couple of days ago) a problem with referring
>>   >> to equations containing an underscore in the label, I am fairly
>>   >> sure it was allowed before, e.g.:
>>   >> 
>>   >> #+LABEL: Equation:new_eq \begin{equation} x=\sqrt{b} \end{equation}
>>   >> 
>>   >> Referring to an equation with an underscore: \ref{Equation:new_eq}
>>   >> 
>>   >> I get a libreoffice popup:
>>   >> 
>>   >> "Read Error. Format error discovered in the file in sub-document
>>   >> content.xmlat 2236,92(row,col)."
>>   >> 
  >> OK - phew (although I may not be out of the woods yet). It seems
  >> that the underscore in the link is interpreted as a subscript:
  >> 
  >> ,---- | ...  | Referring to an equation with an underscore:
  >> <text:sequence-ref | text:ref-name="Equation:new<text:span |
  >> text:style-name="OrgSubscript">eq</text:span>"/> `----

  > Nick, Thanks for debugging this and isolating the root cause.
  > Myles, I have pushed a fix few minutes ago. Hope things are OK now.

References work fine now, Thanks.

Myles

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

end of thread, other threads:[~2011-11-02 21:31 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-23 14:36 [odt] equation labels Myles English
2011-08-26 19:36 ` Jambunathan K
2011-08-27 22:02 ` Jambunathan K
2011-08-31 11:09   ` Myles English
2011-08-31 11:37     ` suvayu ali
2011-08-31 11:50     ` Myles English
2011-08-31 13:52       ` Jambunathan K
2011-08-31 14:07     ` Jambunathan K
2011-09-17 19:48 ` Jambunathan K
  -- strict thread matches above, loose matches on Subject: below --
2011-10-28  1:23 Myles English
2011-10-30 22:11 ` Jambunathan K
2011-10-31 11:54   ` Myles English
2011-11-01 11:17     ` Myles English
2011-11-01 19:39     ` Jambunathan K
2011-11-01 19:49       ` Jambunathan K
2011-11-02 13:18       ` Myles English
     [not found]         ` <mylesenglish@gmail.com>
2011-11-02 13:38           ` Nick Dokos
2011-11-02 14:49             ` Myles English
2011-11-02 14:52           ` Nick Dokos
2011-11-02 18:21             ` Jambunathan K
2011-11-02 21:33               ` Myles English

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).