all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Org, latex and asymptote in a math project
@ 2011-09-12 12:23 Jarmo Hurri
  2011-09-12 13:15 ` Giovanni Ridolfi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jarmo Hurri @ 2011-09-12 12:23 UTC (permalink / raw)
  To: emacs-orgmode


Greetings!

Been exploring org, done some examples, and even bought the t-shirt
because I was so impressed.

In addition to using org to keep my personal faq and notes, I am
currently evaluating the use of org in a major math writing project that
will stretch over several years. My standard math tools are latex,
asymptote, R and maxima, and I see org as a great opportunity to
integrate these.

The overall plan is to do the work in org and then export as both pdf
and html. To this end I did a quick test in which I came up with a few
ideas and questions. It has been many years since I have done any
serious Lisp programming, but in the long run I might be able to
implement the ideas if they would be acceptable.

1. If I have understood correctly, in order for an asymptote image to be
   included as an inline image, one has to specify a file name at the
   beginning of the code block, as in

   #+CAPTION: A test caption.
   #+begin_src asymptote :file foo.pdf
   size (1cm, 0);
   filldraw (unitsquare, red);
   #+end_src

   It would be convenient if the user would not need to specify a
   (unique) invented file name for the inline image. Instead, in the
   case of an exported pdf, as an end user I would like for asymptote to
   generate a unique temporary pdf image file, which would be removed
   after the pdf corresponding to the complete document was
   complete. The case of exported html is not as clear to me yet; my
   current guess is that I would like the system to automatically
   generate a uniquely named image file (preferably an svg image, but
   not sure which browsers support these) which would then be inline
   included into the html page.

   Do these ideas get any support? What would be the best way to denote
   this kind of behaviour? A new option for "#begin_src asymptote",
   e.g., "#begin_src asymptote :autoinline"? Or perhaps
   "#begin_src asymptote :autofile"?

2. At least for me, _by far_ the most common way of referring to a
   floating element (table or figure) is immediately before or after the
   latex code that defines the float. For this, having to generate a
   unique label for the float has always been an overkill, and I have
   wanted a way to just refer to the previous or next float in the
   document. In org this could mean something like specifying
   #+AUTOLABEL and then some way of referring to the labels of the next
   and previous float (regardless of whether they would be automatically
   generated labels or standard named labels). Any support for this? Any
   ideas regarding the syntax?

3. It seems that currently inline images generated by asymptote are
   included in the resulting latex file with a default size
   width=.9\linewidth. I prefer them to be included in their original
   size. To achieve this I first tried to define

   (setq org-export-latex-image-default-option "")

   This did not help: in the resulting latex file, the size was now
   defined as width=.7\textwidth, which seems to come from
   org-latex.el. Finally I obtained the wanted behaviour by artificially
   defining the option to some value that does not cause any harm; in my
   case

   (setq org-export-latex-image-default-option "keepaspectratio=true")

   Like I said, this is artificial. Is there a more natural way to
   achieve the desired result, that is, inclusion of images in their
   original size? Would it be ok if the code were changed so that
   setting 

   (setq org-export-latex-image-default-option "")

   would override the width=.7\textwidth coming from org-latex.el?

4. Let us say that in the math document there would be questions with
   corresponding answers and solutions. An answer would be just the
   result, while the solution would show the steps needed to obtain the
   result. In the org document I would like to write the question, the
   corresponding answer and the solution in one place, one after the
   other, while in the exported pdf / html I would like the answers and
   solutions to be at the end of the document, numbered according to the
   numbers of the questions. How could I achieve this?

I use this opportunity to thank the people behind org-mode for
developing a brilliant system.

-- 
Jarmo Hurri

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

* Re: Org, latex and asymptote in a math project
  2011-09-12 12:23 Org, latex and asymptote in a math project Jarmo Hurri
@ 2011-09-12 13:15 ` Giovanni Ridolfi
  2011-09-12 14:16 ` Jambunathan K
  2011-09-12 15:49 ` Ethan Ligon
  2 siblings, 0 replies; 4+ messages in thread
From: Giovanni Ridolfi @ 2011-09-12 13:15 UTC (permalink / raw)
  To: Jarmo Hurri; +Cc: emacs-orgmode

Jarmo Hurri <jarmo.hurri@syk.fi> writes:

Hi, Jarmo,

> 1. If I have understood correctly, in order for an asymptote image to be
>    included as an inline image, one has to specify a file name at the
>    beginning of the code block, as in
>
>    #+CAPTION: A test caption.
>    #+begin_src asymptote :file foo.pdf
>    size (1cm, 0);
>    filldraw (unitsquare, red);
>    #+end_src
>
>    It would be convenient if the user would not need to specify a
>    (unique) invented file name for the inline image. 
can't you use the link facility?

1. open dired
2. go over the name of the file you need
3. C-c l
   [the path/namefile is saved in the kill ring]
4. back to the buffer you're editing
5. C-c C-l  
   store the link

then you may find worth reading the  section of the manual:
Images in  export
-----------------
     #+CAPTION:    The black-body emission of the disk around HR 4049
     #+LABEL:      fig:SED-HR4049
     #+ATTR_LaTeX: width=5cm,angle=90
     [[./img/sed-hr4049.pdf]]
     
     #+ATTR_LaTeX: width=0.38\textwidth wrap placement={r}{0.4\textwidth}
     [[./img/hst.png]]


> 2. At least for me, _by far_ the most common way of referring to a
>    floating element (table or figure) is immediately before or after the
>    latex code that defines the float. For this, having to generate a
>    unique label for the float has always been an overkill, and I have
>    wanted a way to just refer to the previous or next float in the
>    document. In org this could mean something like specifying
>    #+AUTOLABEL and then some way of referring to the labels of the next
>    and previous float (regardless of whether they would be automatically
>    generated labels or standard named labels). Any support for this? Any
>    ideas regarding the syntax?
maybe you can use the property  :CUSTOM_ID: ? Manual: Internal links

hth,

Giovanni

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

* Re: Org, latex and asymptote in a math project
  2011-09-12 12:23 Org, latex and asymptote in a math project Jarmo Hurri
  2011-09-12 13:15 ` Giovanni Ridolfi
@ 2011-09-12 14:16 ` Jambunathan K
  2011-09-12 15:49 ` Ethan Ligon
  2 siblings, 0 replies; 4+ messages in thread
From: Jambunathan K @ 2011-09-12 14:16 UTC (permalink / raw)
  To: Jarmo Hurri; +Cc: emacs-orgmode


> 2. At least for me, _by far_ the most common way of referring to a
>    floating element (table or figure) is immediately before or after the
>    latex code that defines the float. For this, having to generate a
>    unique label for the float has always been an overkill, and I have
>    wanted a way to just refer to the previous or next float in the
>    document. In org this could mean something like specifying
>    #+AUTOLABEL and then some way of referring to the labels of the next
>    and previous float (regardless of whether they would be automatically
>    generated labels or standard named labels). Any support for this? Any
>    ideas regarding the syntax?


May be you are actually suggesting that the LABELS[1] be generated
automagically for you in much the same way that footnote numbers are
generated.

In case of OpenDocumentFormat, one can have the references generated in
the "Above/Below" formats. This can be controlled purely by controlling
the exporting backend WITHOUT ADDING any new Orgmode syntax. I am not
much familiar with LaTeX. If I interpret what you are saying then you
are suggesting that you have some control over how a given exporter
generates label references.

HTML is really not print oriented (whatever that means). May be the
LABEL references \ref{LABEL} which looks to me to be LaTeX oriented
syntax be re-defined to more Org-link like.

Just my 2c,
Jambunathan K.

Footnotes: 
[1]  I would like to view LABELS as below:

LABEL := CATEGORY:SEQNO

CATEGORY := string
SEQNO := [0-9]+ (not sure whether a period could be included)

CATEGORY could be used for Table, Illustration, Figure etc etc.

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

* Re: Org, latex and asymptote in a math project
  2011-09-12 12:23 Org, latex and asymptote in a math project Jarmo Hurri
  2011-09-12 13:15 ` Giovanni Ridolfi
  2011-09-12 14:16 ` Jambunathan K
@ 2011-09-12 15:49 ` Ethan Ligon
  2 siblings, 0 replies; 4+ messages in thread
From: Ethan Ligon @ 2011-09-12 15:49 UTC (permalink / raw)
  To: emacs-orgmode

Hi, Jarmo-

Jarmo Hurri <jarmo.hurri <at> syk.fi> writes:
> 1. If I have understood correctly, in order for an asymptote image to be
>    included as an inline image, one has to specify a file name at the
>    beginning of the code block, as in
> 
>    #+CAPTION: A test caption.
>    #+begin_src asymptote :file foo.pdf
>    size (1cm, 0);
>    filldraw (unitsquare, red);
>    #+end_src
> 
>    It would be convenient if the user would not need to specify a
>    (unique) invented file name for the inline image. Instead, in the
>    case of an exported pdf, as an end user I would like for asymptote to
>    generate a unique temporary pdf image file, which would be removed
>    after the pdf corresponding to the complete document was
>    complete. The case of exported html is not as clear to me yet; my
>    current guess is that I would like the system to automatically
>    generate a uniquely named image file (preferably an svg image, but
>    not sure which browsers support these) which would then be inline
>    included into the html page.

I'm starting on a textbook project using a similar set of tools.  
I'm making progress, but am still finding lots of little snags; perhaps as we 
both proceed we can share what we've learned.

In any case, using temporary file names is a good idea, which hadn't occurred to
me.  But I guess it's easy to do, using something like

#+CAPTION: A test caption.
#+begin_src asymptote :file (org-babel-temp-file "figure-" ".pdf")
   size (1cm, 0);
   filldraw (unitsquare, red);
#+end_src

> 2. At least for me, _by far_ the most common way of referring to a
>    floating element (table or figure) is immediately before or after the
>    latex code that defines the float. For this, having to generate a
>    unique label for the float has always been an overkill, and I have
>    wanted a way to just refer to the previous or next float in the
>    document. In org this could mean something like specifying
>    #+AUTOLABEL and then some way of referring to the labels of the next
>    and previous float (regardless of whether they would be automatically
>    generated labels or standard named labels). Any support for this? Any
>    ideas regarding the syntax?

How would one implement this behavior in LaTeX?  

> 3. It seems that currently inline images generated by asymptote are
>    included in the resulting latex file with a default size
>    width=.9\linewidth. I prefer them to be included in their original
>    size. To achieve this I first tried to define
> 
>    (setq org-export-latex-image-default-option "")
> 
>    This did not help: in the resulting latex file, the size was now
>    defined as width=.7\textwidth, which seems to come from
>    org-latex.el. Finally I obtained the wanted behaviour by artificially
>    defining the option to some value that does not cause any harm; in my
>    case
> 
>    (setq org-export-latex-image-default-option "keepaspectratio=true")
> 
>    Like I said, this is artificial. Is there a more natural way to
>    achieve the desired result, that is, inclusion of images in their
>    original size? Would it be ok if the code were changed so that
>    setting 
> 
>    (setq org-export-latex-image-default-option "")
> 
>    would override the width=.7\textwidth coming from org-latex.el?

This was one of the "snags" for me that I mentioned above.  But this
works:

#+CAPTION: A test caption.
#+Attr_LaTeX: width=\textwidth
#+begin_src asymptote :file (org-babel-temp-file "figure-" ".pdf")
   size (1cm, 0);
   filldraw (unitsquare, red);
#+end_src


> 
> 4. Let us say that in the math document there would be questions with
>    corresponding answers and solutions. An answer would be just the
>    result, while the solution would show the steps needed to obtain the
>    result. In the org document I would like to write the question, the
>    corresponding answer and the solution in one place, one after the
>    other, while in the exported pdf / html I would like the answers and
>    solutions to be at the end of the document, numbered according to the
>    numbers of the questions. How could I achieve this?
> 

Haven't done this, but the LaTeX code could put the answers and
solutions in a float, which could then be floated to the end of the
document.

-Ethan

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

end of thread, other threads:[~2011-09-12 15:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-12 12:23 Org, latex and asymptote in a math project Jarmo Hurri
2011-09-12 13:15 ` Giovanni Ridolfi
2011-09-12 14:16 ` Jambunathan K
2011-09-12 15:49 ` Ethan Ligon

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.