emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Exporting property values to LaTeX
@ 2010-09-09 11:42 Scot Becker
  2010-09-09 13:44 ` David Maus
  0 siblings, 1 reply; 4+ messages in thread
From: Scot Becker @ 2010-09-09 11:42 UTC (permalink / raw)
  To: Org-mode ml


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

SHORT VERSION:

Can someone tell me how I might be able to get a property value exported to
LaTeX?  Here's what I want to do:  I my reading and research notes in
org-mode.  I'd like to print them out to manipulate them manually before I
use them.  (Think: olde time 3 x 5 index cards, though I'll do it on A5 size
paper).  I'd like to define an inherited property in my org outline
containing my BibTeX key for the given book or journal article.  The idea is
that all of the notes on that book inherit the property (I can do this
already).  Then I want to export these notes to LaTeX and insert the value
of the 'bibtexkey' property into a custom latex citation command for each
exported node.  That way, when the notes are printed separate from each
other, I have the bibliographic information on each note.

EXAMPLE:

---------------------------------
* Notes taken while reading: Smith, Some-Wild-Book
  :PROPERTIES:
  :bibkey:   smith2009somewild
  :END:

** The Problem

Smith starts with a scorching analysis of the problem:

#+BEGIN_QUOTE
As I see it, this chaos has all arisen because of... (29)
#+END_QUOTE

** The Solution

Summary: Smith thinks that if we would all only listen to him, these
problems would go away. (235)

** Evaluation

Though Smith's audacity is unendurable, he does a few good points,
including...

-------------------------

I'd like to end up with a LaTeX file which will will print the above as
three separate (A5 size) pages. (I think I can do that).  But each note
("The Problem", "The Solution", "Evaluation") gets the value of the
'bibtexkey' property exported in the format:

\shortcite{<bibtexkey>}

immediately after the heading for that section.  I would do this with all
child headings no matter at what level.  Then when I take notes on another
item, its children inherit the correct value of 'bibtexkey' for it.

I think I have property inheritance worked out, and I reckon I can manage to
get org to export the headings how I want them (with
org-export-latex-classes), and I think I can mange to get LaTeX to lay it
all out right (it's LaTeX, how hard could custom layout be? :-).

What I want is a way to tweak org's LaTeX exporter to export "\shortcite{
<value> }" after every heading, with the value of the 'bibtexkey' property
inside it.

I suppose my question is: can anyone think of a way to do this without
making a custom LaTeX exporter?  Does the idea of exporting properties for
use in LaTeX output have enough value to warrant more general solution, for
example allowing placeholders for optional property values in (for example)
'org-export-latex-classes'?  Like this:

 ("\\section{%s}" . "\\section*{%s}\n\n\\shortcite{[[bibtexkey]]}")


Scot

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

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Exporting property values to LaTeX
  2010-09-09 11:42 Exporting property values to LaTeX Scot Becker
@ 2010-09-09 13:44 ` David Maus
  2010-09-09 15:40   ` Scot Becker
  0 siblings, 1 reply; 4+ messages in thread
From: David Maus @ 2010-09-09 13:44 UTC (permalink / raw)
  To: Scot Becker; +Cc: Org-mode ml


[-- Attachment #1.1.1: Type: text/plain, Size: 739 bytes --]

Scot Becker wrote:
>[1  <multipart/alternative (7bit)>]
>[1.1  <text/plain; ISO-8859-1 (7bit)>]

>[1.2  <text/html; ISO-8859-1 (quoted-printable)>]
>SHORT VERSION:

>Can someone tell me how I might be able to get a property value exported to LaTeX?

This is currently not possible but attached patch adds a new macro
(cf. Manual, 11.6 Macro replacement) that inserts a property of the
current subtree.

Example:

{{{property(id)}}}

Will insert the ID property of current subtree if the Org buffer is
exported.

This patch only works for singe value properties and raises an error
if the macro is inserted above the first headline.

Best,
  -- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.1.2: 0001-Provide-new-macro-to-insert-entry-property.patch --]
[-- Type: text/plain, Size: 1054 bytes --]

From ca968bee5a935229370555e9ad915d12e2eb22ab Mon Sep 17 00:00:00 2001
From: David Maus <dmaus@ictsoc.de>
Date: Thu, 9 Sep 2010 15:38:07 +0200
Subject: [PATCH] Provide new macro to insert entry property

* org-exp.el (org-infile-export-plist): Provide new macro to insert
entry property.

Format: {{{property(PROP)}}}, where PROP is the name of the property.
This currently only works for single value properties and fails with
an error if used above the first headline.
---
 lisp/org-exp.el |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index c16bec8..64ad454 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -771,6 +771,7 @@ modified) list.")
 	;; Add macro definitions
 	(setq p (plist-put p :macro-date "(eval (format-time-string \"$1\"))"))
 	(setq p (plist-put p :macro-time "(eval (format-time-string \"$1\"))"))
+	(setq p (plist-put p :macro-property "(eval (org-entry-get nil \"$1\"))"))
 	(setq p (plist-put
 		 p :macro-modification-time
 		 (and (buffer-file-name)
-- 
1.7.1


[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Exporting property values to LaTeX
  2010-09-09 13:44 ` David Maus
@ 2010-09-09 15:40   ` Scot Becker
  2010-09-09 16:03     ` David Maus
  0 siblings, 1 reply; 4+ messages in thread
From: Scot Becker @ 2010-09-09 15:40 UTC (permalink / raw)
  To: David Maus; +Cc: Org-mode ml


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

David,

Thanks for your response.  What a cool and useful patch.   This adds all
kinds of cool functionality to org-mode, and in a single line!    I've had
several times I wished I could do this kind of thing.

As it is, it doesn't automate my present case much, since I'd still have to
put the macro expansion in after every headline.  Not surprisingly it won't
expand if you put the {{{property(myproperty}}} code as part of a headline
in org-export-latex-classes.  I reckon I'll have to try to do a hacked-up
latex exporter.

Also, the patch doesn't seem to work with inherited properties.  With
org-use-property-inheritance set to 't', and this input file:
----------------
* Notes taken while reading: Smith, Some-Wild-Book
  :PROPERTIES:
  :bibkey:   smith2009somewild
  :END:

This here is the key:  {{{property(bibkey)}}}.

** The Problem
This here is the key:  {{{property(bibkey)}}}.
------------------------

I get this output:

-------------------------
\section{Notes taken while reading: Smith, Some-Wild-Book}
\label{sec-1}


This here is the key:  smith2009somewild.
\subsection{The Problem}
\label{sec-1_1}

This here is the key:  \{{\{property(bibkey)\}}\}.
---------------------------


Cheers,

Scot

On Thu, Sep 9, 2010 at 2:44 PM, David Maus <dmaus@ictsoc.de> wrote:

> Scot Becker wrote:
> >[1  <multipart/alternative (7bit)>]
> >[1.1  <text/plain; ISO-8859-1 (7bit)>]
>
> >[1.2  <text/html; ISO-8859-1 (quoted-printable)>]
> >SHORT VERSION:
>
> >Can someone tell me how I might be able to get a property value exported
> to LaTeX?
>
> This is currently not possible but attached patch adds a new macro
> (cf. Manual, 11.6 Macro replacement) that inserts a property of the
> current subtree.
>
> Example:
>
> {{{property(id)}}}
>
> Will insert the ID property of current subtree if the Org buffer is
> exported.
>
> This patch only works for singe value properties and raises an error
> if the macro is inserted above the first headline.
>
> Best,
>  -- David
> --
> OpenPGP... 0x99ADB83B5A4478E6
> Jabber.... dmjena@jabber.org
> Email..... dmaus@ictsoc.de
>

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

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Exporting property values to LaTeX
  2010-09-09 15:40   ` Scot Becker
@ 2010-09-09 16:03     ` David Maus
  0 siblings, 0 replies; 4+ messages in thread
From: David Maus @ 2010-09-09 16:03 UTC (permalink / raw)
  To: Scot Becker; +Cc: David Maus, Org-mode ml


[-- Attachment #1.1.1: Type: text/plain, Size: 1969 bytes --]

Scot Becker wrote:
>David,

>Thanks for your response.  What a cool and useful patch.   This adds all kinds of cool functionality to org-mode, and in a
>single line!    I've had several times I wished I could do this kind of thing. 

>As it is, it doesn't automate my present case much, since I'd still have to put the macro expansion in after every
>headline.  Not surprisingly it won't expand if you put the {{{property(myproperty}}} code as part of a headline in
>org-export-latex-classes.  I reckon I'll have to try to do a hacked-up latex exporter.

Or maybe this could be achieved using a function in
`org-export-preprocess-hook':

,----
| Hook for preprocessing an export buffer.
| Pretty much the first thing when exporting is running this hook.
| Point will be in a temporary buffer that contains a copy of
| the original buffer, or of the section that is being export.
| All the other hooks in the org-export-preprocess... category
| also work in that temporary buffer, already modified by various
| stages of the processing.
`----

The function would be quite simple: Iterate over all headlines and
insert the desired reference.  This would, by the way, even work
without the property macro.

Something like this:

(defun dmj:add-citekey ()
  "Add citekey to all headlines in current buffer."
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward "\\*+[ \t]+" nil t)
      (let ((key (org-entry-get nil "mykey" 'selective)))
	(org-end-of-subtree t)
	(unless (string= key "")
	  (insert (format "\nReference: \\cite{%s}\n" key)))))))

>Also, the patch doesn't seem to work with inherited properties.  With
>org-use-property-inheritance set to 't', and this input file:

Ah, Forgot about that.  Attached patch goes on top of the last one and
allows property inheritance.

Best,
  -- David
-- 
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.1.2: 0001-Allow-selective-property-inheritance-in-property-mac.patch --]
[-- Type: text/plain, Size: 984 bytes --]

From 37abd340b23d37328c34bf524f4c80f7b1ce9b0e Mon Sep 17 00:00:00 2001
From: David Maus <dmaus@ictsoc.de>
Date: Thu, 9 Sep 2010 17:46:42 +0200
Subject: [PATCH] Allow selective property inheritance in property macro

* org-exp.el (org-infile-export-plist): Allow selective property
inheritance in property macro.
---
 lisp/org-exp.el |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 64ad454..28157a8 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -771,7 +771,7 @@ modified) list.")
 	;; Add macro definitions
 	(setq p (plist-put p :macro-date "(eval (format-time-string \"$1\"))"))
 	(setq p (plist-put p :macro-time "(eval (format-time-string \"$1\"))"))
-	(setq p (plist-put p :macro-property "(eval (org-entry-get nil \"$1\"))"))
+	(setq p (plist-put p :macro-property "(eval (org-entry-get nil \"$1\" 'selective))"))
 	(setq p (plist-put
 		 p :macro-modification-time
 		 (and (buffer-file-name)
-- 
1.7.1


[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

end of thread, other threads:[~2010-09-09 16:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-09 11:42 Exporting property values to LaTeX Scot Becker
2010-09-09 13:44 ` David Maus
2010-09-09 15:40   ` Scot Becker
2010-09-09 16:03     ` David Maus

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