emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Integration of RefTeX and LaTeX export
@ 2012-02-16 20:59 Andreas Willig
  2012-02-16 22:08 ` Thomas S. Dye
  0 siblings, 1 reply; 11+ messages in thread
From: Andreas Willig @ 2012-02-16 20:59 UTC (permalink / raw)
  To: emacs-orgmode


Hi,

i am relatively new to org mode. Yesterday i have tried to use org mode for
the first time to write the beginnings of a paper, and found that i wanted to
insert literature references and a bibliography. I like RefTeX a lot and google
provided me some links for proper integration. As a result, i have added the
stuff to my .emacs that you find below. The "org-latex-to-pdf-process" stuff
works.

My problems are related to (reftex-set-cite-format ..). Right now i do not use
it and get the default implementation by which RefTeX simply expands the
chosen reference to \cite{Key}, which is not highlighted in the org buffer. I would
like to have this expanded into an org link with the [[][]] syntax. I have tried
several variations of (reftex-set-cite-format ...) but i have never succeeded in
creating the bibliography. After generating the LaTeX output into a buffer 
(C-c C-e L) i found that org translates [[][]] type of stuff into \hyperref{}s and not
into \cite{} commands.

So, how can i change things so that in the org buffer the bib key gets displayed
nicely and in the LaTeX output a \cite{} command is generated?

Any help would be appreciated!!

Best regards,

Andreas

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

(require 'org-latex)
(unless (boundp 'org-export-latex-classes)
  (setq org-export-latex-classes nil))


(add-to-list 'org-export-latex-classes
             '("article"
               "\\documentclass{article}"
               ("\\section{%s}" . "\\section*{%s}")
               ("\\subsection{%s}" . "\\subsection*{%s}")
               ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
               ("\\paragraph{%s}" . "\\paragraph*{%s}")))  

(add-to-list 'org-export-latex-classes
             '("komaarticle"
               "\\documentclass{scrartcl}"
               ("\\section{%s}" . "\\section*{%s}")
               ("\\subsection{%s}" . "\\subsection*{%s}")
               ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
               ("\\paragraph{%s}" . "\\paragraph*{%s}")))  


(add-to-list 'org-export-latex-classes
             '("komabook"
               "\\documentclass{scrbook}"
               ("\\chapter{%s}" . "\\chapter*{%s}")
               ("\\section{%s}" . "\\section*{%s}")
               ("\\subsection{%s}" . "\\subsection*{%s}")
               ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
               ("\\paragraph{%s}" . "\\paragraph*{%s}")))  


(defun org-mode-reftex-setup ()
  (load-library "reftex")
  (and (buffer-file-name) (file-exists-p (buffer-file-name))
       (progn
	 (global-auto-revert-mode t)
	 (reftex-parse-all)
	 ;;(reftex-set-cite-format "\[cite][%l]]")
	 ))
  (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
  (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search))

(add-hook 'org-mode-hook 'org-mode-reftex-setup)


(defun org-mode-reftex-search ()
  ;;jump to the notes for the paper pointed to at from reftex search
  (interactive)
  (org-open-link-from-string (format "[[notes:%s]]" (reftex-citation t))))
 
(setq org-latex-to-pdf-process
        '("pdflatex -interaction nonstopmode %b"
          "bibtex %b"
          "pdflatex -interaction nonstopmode %b"
          "pdflatex -interaction nonstopmode %b"))

 
This email may be confidential and subject to legal privilege, it may
not reflect the views of the University of Canterbury, and it is not
guaranteed to be virus free. If you are not an intended recipient,
please notify the sender immediately and erase all copies of the message
and any attachments.

Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more
information.

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

* Re: Integration of RefTeX and LaTeX export
  2012-02-16 20:59 Integration of RefTeX and LaTeX export Andreas Willig
@ 2012-02-16 22:08 ` Thomas S. Dye
  2012-02-17  4:46   ` Andreas Willig
  0 siblings, 1 reply; 11+ messages in thread
From: Thomas S. Dye @ 2012-02-16 22:08 UTC (permalink / raw)
  To: Andreas Willig; +Cc: emacs-orgmode

Andreas Willig <andreas.willig@canterbury.ac.nz> writes:

> Hi,
>
> i am relatively new to org mode. Yesterday i have tried to use org mode for
> the first time to write the beginnings of a paper, and found that i wanted to
> insert literature references and a bibliography. I like RefTeX a lot and google
> provided me some links for proper integration. As a result, i have added the
> stuff to my .emacs that you find below. The "org-latex-to-pdf-process" stuff
> works.
>
> My problems are related to (reftex-set-cite-format ..). Right now i do not use
> it and get the default implementation by which RefTeX simply expands the
> chosen reference to \cite{Key}, which is not highlighted in the org buffer. I would
> like to have this expanded into an org link with the [[][]] syntax. I have tried
> several variations of (reftex-set-cite-format ...) but i have never succeeded in
> creating the bibliography. After generating the LaTeX output into a buffer 
> (C-c C-e L) i found that org translates [[][]] type of stuff into \hyperref{}s and not
> into \cite{} commands.
>
> So, how can i change things so that in the org buffer the bib key gets displayed
> nicely and in the LaTeX output a \cite{} command is generated?
>
> Any help would be appreciated!!
>
> Best regards,
>
> Andreas
>
> --------------------------------------
>
> (require 'org-latex)
> (unless (boundp 'org-export-latex-classes)
>   (setq org-export-latex-classes nil))
>
>
> (add-to-list 'org-export-latex-classes
>              '("article"
>                "\\documentclass{article}"
>                ("\\section{%s}" . "\\section*{%s}")
>                ("\\subsection{%s}" . "\\subsection*{%s}")
>                ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
>                ("\\paragraph{%s}" . "\\paragraph*{%s}")))  
>
> (add-to-list 'org-export-latex-classes
>              '("komaarticle"
>                "\\documentclass{scrartcl}"
>                ("\\section{%s}" . "\\section*{%s}")
>                ("\\subsection{%s}" . "\\subsection*{%s}")
>                ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
>                ("\\paragraph{%s}" . "\\paragraph*{%s}")))  
>
>
> (add-to-list 'org-export-latex-classes
>              '("komabook"
>                "\\documentclass{scrbook}"
>                ("\\chapter{%s}" . "\\chapter*{%s}")
>                ("\\section{%s}" . "\\section*{%s}")
>                ("\\subsection{%s}" . "\\subsection*{%s}")
>                ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
>                ("\\paragraph{%s}" . "\\paragraph*{%s}")))  
>
>
> (defun org-mode-reftex-setup ()
>   (load-library "reftex")
>   (and (buffer-file-name) (file-exists-p (buffer-file-name))
>        (progn
> 	 (global-auto-revert-mode t)
> 	 (reftex-parse-all)
> 	 ;;(reftex-set-cite-format "\[cite][%l]]")
> 	 ))
>   (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
>   (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search))
>
> (add-hook 'org-mode-hook 'org-mode-reftex-setup)
>
>
> (defun org-mode-reftex-search ()
>   ;;jump to the notes for the paper pointed to at from reftex search
>   (interactive)
>   (org-open-link-from-string (format "[[notes:%s]]" (reftex-citation t))))
>  
> (setq org-latex-to-pdf-process
>         '("pdflatex -interaction nonstopmode %b"
>           "bibtex %b"
>           "pdflatex -interaction nonstopmode %b"
>           "pdflatex -interaction nonstopmode %b"))
>
>  
> This email may be confidential and subject to legal privilege, it may
> not reflect the views of the University of Canterbury, and it is not
> guaranteed to be virus free. If you are not an intended recipient,
> please notify the sender immediately and erase all copies of the message
> and any attachments.
>
> Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more
> information.
>
>
Aloha Andreas,

Welcome to Org Mode!

You might want to define a new link type.  See
http://orgmode.org/worg/org-tutorials/org-latex-export.html#sec-17-2 for
one example of how this might be done.

hth,
Tom
-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: Integration of RefTeX and LaTeX export
  2012-02-16 22:08 ` Thomas S. Dye
@ 2012-02-17  4:46   ` Andreas Willig
  2012-02-17  5:31     ` Nick Dokos
  0 siblings, 1 reply; 11+ messages in thread
From: Andreas Willig @ 2012-02-17  4:46 UTC (permalink / raw)
  To: Thomas S.Dye; +Cc: emacs-orgmode


Hi Thomas,

thanks for this hint. I have looked at this, the changed / added functions are
below, everything else has not changed. I still have a problem.

I have created a new link type as you suggested and have consulted google
on how to do it (my emacs-lisp-fu is not good enough to sort out directly what
this function is doing ...). In my understanding the third argument is a function
that is called when an export process has started and a link is about to be
exported. My first problem is: this handler function is never called, the error
message that i have inserted below does never appear. I have seen that the
variable "org-link-types" contains the defined link type, and the variable
"org-link-protocols" shows my handler.

My second problem is that the generated LaTeX output is
  "\texttt{\cite{key}}"
but it should simply be "\cite{key}". I would guess that the second problem
is a corollary of the first one ...

Any ideas?

Andreas

============================================

(defun rt-handler (path)
  (message "dummy handler called, path = %s" path)
  (let ((arg (concat "\\cite{" path "}")))
    (reftex-view-crossref arg)))

(org-add-link-type "rtcite" 
		   'rt-handler
		   (lambda (path desc format)
		     (error "my handler is called")
		     (cond ((eq format 'latex)
			    (if (or (not desc) (equal 0 (search "rtcite:" desc)))
				(format "\\cite{%s}" path)
			      (format "\\cite[%s]{%s}" desc path))))))


(defun org-mode-reftex-setup ()
  (load-library "reftex")
  (and (buffer-file-name) (file-exists-p (buffer-file-name))
       (progn
	 ;;enable auto-revert-mode to update reftex when bibtex file changes on disk
	 (global-auto-revert-mode t)
	 (reftex-parse-all)
	 ;;add a custom reftex cite format to insert links
	 (reftex-set-cite-format "[[rtcite:%l][\\cite{%l}]]")
	 ))
  (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
  (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search))

============================================

On 17/02/2012, at 11:08 AM, Thomas S. Dye wrote:

> Andreas Willig <andreas.willig@canterbury.ac.nz> writes:
> 
>> Hi,
>> 
>> i am relatively new to org mode. Yesterday i have tried to use org mode for
>> the first time to write the beginnings of a paper, and found that i wanted to
>> insert literature references and a bibliography. I like RefTeX a lot and google
>> provided me some links for proper integration. As a result, i have added the
>> stuff to my .emacs that you find below. The "org-latex-to-pdf-process" stuff
>> works.
>> 
>> My problems are related to (reftex-set-cite-format ..). Right now i do not use
>> it and get the default implementation by which RefTeX simply expands the
>> chosen reference to \cite{Key}, which is not highlighted in the org buffer. I would
>> like to have this expanded into an org link with the [[][]] syntax. I have tried
>> several variations of (reftex-set-cite-format ...) but i have never succeeded in
>> creating the bibliography. After generating the LaTeX output into a buffer 
>> (C-c C-e L) i found that org translates [[][]] type of stuff into \hyperref{}s and not
>> into \cite{} commands.
>> 
>> So, how can i change things so that in the org buffer the bib key gets displayed
>> nicely and in the LaTeX output a \cite{} command is generated?
>> 
>> Any help would be appreciated!!
>> 
>> Best regards,
>> 
>> Andreas
>> 
>> --------------------------------------
>> 
>> (require 'org-latex)
>> (unless (boundp 'org-export-latex-classes)
>>  (setq org-export-latex-classes nil))
>> 
>> 
>> (add-to-list 'org-export-latex-classes
>>             '("article"
>>               "\\documentclass{article}"
>>               ("\\section{%s}" . "\\section*{%s}")
>>               ("\\subsection{%s}" . "\\subsection*{%s}")
>>               ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
>>               ("\\paragraph{%s}" . "\\paragraph*{%s}")))  
>> 
>> (add-to-list 'org-export-latex-classes
>>             '("komaarticle"
>>               "\\documentclass{scrartcl}"
>>               ("\\section{%s}" . "\\section*{%s}")
>>               ("\\subsection{%s}" . "\\subsection*{%s}")
>>               ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
>>               ("\\paragraph{%s}" . "\\paragraph*{%s}")))  
>> 
>> 
>> (add-to-list 'org-export-latex-classes
>>             '("komabook"
>>               "\\documentclass{scrbook}"
>>               ("\\chapter{%s}" . "\\chapter*{%s}")
>>               ("\\section{%s}" . "\\section*{%s}")
>>               ("\\subsection{%s}" . "\\subsection*{%s}")
>>               ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
>>               ("\\paragraph{%s}" . "\\paragraph*{%s}")))  
>> 
>> 
>> (defun org-mode-reftex-setup ()
>>  (load-library "reftex")
>>  (and (buffer-file-name) (file-exists-p (buffer-file-name))
>>       (progn
>> 	 (global-auto-revert-mode t)
>> 	 (reftex-parse-all)
>> 	 ;;(reftex-set-cite-format "\[cite][%l]]")
>> 	 ))
>>  (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
>>  (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search))
>> 
>> (add-hook 'org-mode-hook 'org-mode-reftex-setup)
>> 
>> 
>> (defun org-mode-reftex-search ()
>>  ;;jump to the notes for the paper pointed to at from reftex search
>>  (interactive)
>>  (org-open-link-from-string (format "[[notes:%s]]" (reftex-citation t))))
>> 
>> (setq org-latex-to-pdf-process
>>        '("pdflatex -interaction nonstopmode %b"
>>          "bibtex %b"
>>          "pdflatex -interaction nonstopmode %b"
>>          "pdflatex -interaction nonstopmode %b"))
>> 
>> 
>> This email may be confidential and subject to legal privilege, it may
>> not reflect the views of the University of Canterbury, and it is not
>> guaranteed to be virus free. If you are not an intended recipient,
>> please notify the sender immediately and erase all copies of the message
>> and any attachments.
>> 
>> Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more
>> information.
>> 
>> 
> Aloha Andreas,
> 
> Welcome to Org Mode!
> 
> You might want to define a new link type.  See
> http://orgmode.org/worg/org-tutorials/org-latex-export.html#sec-17-2 for
> one example of how this might be done.
> 
> hth,
> Tom
> -- 
> Thomas S. Dye
> http://www.tsdye.com


This email may be confidential and subject to legal privilege, it may
not reflect the views of the University of Canterbury, and it is not
guaranteed to be virus free. If you are not an intended recipient,
please notify the sender immediately and erase all copies of the message
and any attachments.

Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more
information.

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

* Re: Integration of RefTeX and LaTeX export
  2012-02-17  4:46   ` Andreas Willig
@ 2012-02-17  5:31     ` Nick Dokos
  2012-02-17  7:39       ` Andreas Willig
  2012-03-23 16:14       ` Navigatable and exportable bib/notes links - Was: " Olivier Berger
  0 siblings, 2 replies; 11+ messages in thread
From: Nick Dokos @ 2012-02-17  5:31 UTC (permalink / raw)
  To: Andreas Willig; +Cc: nicholas.dokos, emacs-orgmode

Andreas Willig <andreas.willig@canterbury.ac.nz> wrote:

> 
> Hi Thomas,
> 
> thanks for this hint. I have looked at this, the changed / added functions are
> below, everything else has not changed. I still have a problem.
> 
> I have created a new link type as you suggested and have consulted google
> on how to do it (my emacs-lisp-fu is not good enough to sort out directly what
> this function is doing ...). In my understanding the third argument is a function
> that is called when an export process has started and a link is about to be
> exported. My first problem is: this handler function is never called, the error
> message that i have inserted below does never appear. I have seen that the
> variable "org-link-types" contains the defined link type, and the variable
> "org-link-protocols" shows my handler.
> 
> My second problem is that the generated LaTeX output is
>   "\texttt{\cite{key}}"
> but it should simply be "\cite{key}". I would guess that the second problem
> is a corollary of the first one ...
> 
> Any ideas?
> 
> Andreas
> 

I'm pretty sure the second function is not quoted properly in your
org-add-link-type so it ends up actually getting called at the time of
the org-add-link-type is called.

Try the following:

--8<---------------cut here---------------start------------->8---
(defun rt-follow-handler (path)
  (message "dummy handler called, path = %s" path)
  (let ((arg (concat "\\cite{" path "}")))
    (reftex-view-crossref arg)))

(defun rt-export-handler  (path desc format)
  (message "my handler is called")
  (cond ((eq format 'latex)
	 (if (or (not desc) (equal 0 (search "rtcite:" desc)))
	     (format "\\cite{%s}" path)
	   (format "\\cite[%s]{%s}" desc path)))))

(require 'org)
(org-add-link-type "rtcite" 
		   (function rt-follow-handler)
		   (function rt-export-handler))
--8<---------------cut here---------------end--------------->8---

By way of explanation:

I had this as part of a minimal .emacs and it seems to work more or
less OK: I replaced the error call with a message call, because it
actually triggered and blew up :-) The rt-export-handler needs tweaking
but you 'll know what to do better than I do when you see the latex
output.

I had to (require 'org) to pick up the definition of org-add-link-type:
that seems to be a missing autoload somewhere.

And finally I like to quote functions with function, not quote, for
compiled-code reasons, but in most cases, it won't make any difference:
use quotes if you prefer.

Nick

> ============================================
> 
> (defun rt-handler (path)
>   (message "dummy handler called, path = %s" path)
>   (let ((arg (concat "\\cite{" path "}")))
>     (reftex-view-crossref arg)))
> 
> (org-add-link-type "rtcite" 
> 		   'rt-handler
> 		   (lambda (path desc format)
> 		     (error "my handler is called")
> 		     (cond ((eq format 'latex)
> 			    (if (or (not desc) (equal 0 (search "rtcite:" desc)))
> 				(format "\\cite{%s}" path)
> 			      (format "\\cite[%s]{%s}" desc path))))))
> 
> 
> ....

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

* Re: Integration of RefTeX and LaTeX export
  2012-02-17  5:31     ` Nick Dokos
@ 2012-02-17  7:39       ` Andreas Willig
  2012-02-17  8:10         ` Andreas Willig
  2012-03-23 16:14       ` Navigatable and exportable bib/notes links - Was: " Olivier Berger
  1 sibling, 1 reply; 11+ messages in thread
From: Andreas Willig @ 2012-02-17  7:39 UTC (permalink / raw)
  Cc: nicholas.dokos, emacs-orgmode


Hi Nick,

thanks for this, but i cannot get it to work ...
I have started a vanilla emacs without any init file
(emacs -q), have loaded your snippet from a file and
evaluated the buffer. Again, the export-handler does
not get called. I am running Debian 6.0.4 and my emacs
is the one coming with it (see below).

I feel so stupid :-))

Andreas


M-x emacs-version says: GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version 2.20.0) of 2010-12-12 on raven, modified by Debian

M-x org-version says: Org-mode version 6.33x

Debian version is 6.0.4 (/etc/debian_version)



-----Original Message-----
From: Nick Dokos [mailto:nicholas.dokos@hp.com]
Sent: Fri 2/17/2012 6:31 PM
To: Andreas Willig
Cc: Thomas S.Dye; emacs-orgmode@gnu.org; nicholas.dokos@hp.com
Subject: Re: [O] Integration of RefTeX and LaTeX export
 
Andreas Willig <andreas.willig@canterbury.ac.nz> wrote:

> 
> Hi Thomas,
> 
> thanks for this hint. I have looked at this, the changed / added functions are
> below, everything else has not changed. I still have a problem.
> 
> I have created a new link type as you suggested and have consulted google
> on how to do it (my emacs-lisp-fu is not good enough to sort out directly what
> this function is doing ...). In my understanding the third argument is a function
> that is called when an export process has started and a link is about to be
> exported. My first problem is: this handler function is never called, the error
> message that i have inserted below does never appear. I have seen that the
> variable "org-link-types" contains the defined link type, and the variable
> "org-link-protocols" shows my handler.
> 
> My second problem is that the generated LaTeX output is
>   "\texttt{\cite{key}}"
> but it should simply be "\cite{key}". I would guess that the second problem
> is a corollary of the first one ...
> 
> Any ideas?
> 
> Andreas
> 

I'm pretty sure the second function is not quoted properly in your
org-add-link-type so it ends up actually getting called at the time of
the org-add-link-type is called.

Try the following:

--8<---------------cut here---------------start------------->8---
(defun rt-follow-handler (path)
  (message "dummy handler called, path = %s" path)
  (let ((arg (concat "\\cite{" path "}")))
    (reftex-view-crossref arg)))

(defun rt-export-handler  (path desc format)
  (message "my handler is called")
  (cond ((eq format 'latex)
	 (if (or (not desc) (equal 0 (search "rtcite:" desc)))
	     (format "\\cite{%s}" path)
	   (format "\\cite[%s]{%s}" desc path)))))

(require 'org)
(org-add-link-type "rtcite" 
		   (function rt-follow-handler)
		   (function rt-export-handler))
--8<---------------cut here---------------end--------------->8---

By way of explanation:

I had this as part of a minimal .emacs and it seems to work more or
less OK: I replaced the error call with a message call, because it
actually triggered and blew up :-) The rt-export-handler needs tweaking
but you 'll know what to do better than I do when you see the latex
output.

I had to (require 'org) to pick up the definition of org-add-link-type:
that seems to be a missing autoload somewhere.

And finally I like to quote functions with function, not quote, for
compiled-code reasons, but in most cases, it won't make any difference:
use quotes if you prefer.

Nick

> ============================================
> 
> (defun rt-handler (path)
>   (message "dummy handler called, path = %s" path)
>   (let ((arg (concat "\\cite{" path "}")))
>     (reftex-view-crossref arg)))
> 
> (org-add-link-type "rtcite" 
> 		   'rt-handler
> 		   (lambda (path desc format)
> 		     (error "my handler is called")
> 		     (cond ((eq format 'latex)
> 			    (if (or (not desc) (equal 0 (search "rtcite:" desc)))
> 				(format "\\cite{%s}" path)
> 			      (format "\\cite[%s]{%s}" desc path))))))
> 
> 
> ....


This email may be confidential and subject to legal privilege, it may
not reflect the views of the University of Canterbury, and it is not
guaranteed to be virus free. If you are not an intended recipient,
please notify the sender immediately and erase all copies of the message
and any attachments.

Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more
information.

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

* Re: Integration of RefTeX and LaTeX export
  2012-02-17  7:39       ` Andreas Willig
@ 2012-02-17  8:10         ` Andreas Willig
  2012-02-17  8:36           ` Andreas Willig
  0 siblings, 1 reply; 11+ messages in thread
From: Andreas Willig @ 2012-02-17  8:10 UTC (permalink / raw)
  To: Andreas Willig; +Cc: nicholas.dokos, emacs-orgmode


I should have added that the rt-follow-hander is properly called ...

Is this a version problem?

-----Original Message-----
From: emacs-orgmode-bounces+andreas.willig=canterbury.ac.nz@gnu.org on behalf of Andreas Willig
Sent: Fri 2/17/2012 8:39 PM
To: nicholas.dokos@hp.com
Cc: nicholas.dokos@hp.com; emacs-orgmode@gnu.org
Subject: Re: [O] Integration of RefTeX and LaTeX export
 

Hi Nick,

thanks for this, but i cannot get it to work ...
I have started a vanilla emacs without any init file
(emacs -q), have loaded your snippet from a file and
evaluated the buffer. Again, the export-handler does
not get called. I am running Debian 6.0.4 and my emacs
is the one coming with it (see below).

I feel so stupid :-))

Andreas


M-x emacs-version says: GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version 2.20.0) of 2010-12-12 on raven, modified by Debian

M-x org-version says: Org-mode version 6.33x

Debian version is 6.0.4 (/etc/debian_version)



-----Original Message-----
From: Nick Dokos [mailto:nicholas.dokos@hp.com]
Sent: Fri 2/17/2012 6:31 PM
To: Andreas Willig
Cc: Thomas S.Dye; emacs-orgmode@gnu.org; nicholas.dokos@hp.com
Subject: Re: [O] Integration of RefTeX and LaTeX export
 
Andreas Willig <andreas.willig@canterbury.ac.nz> wrote:

> 
> Hi Thomas,
> 
> thanks for this hint. I have looked at this, the changed / added functions are
> below, everything else has not changed. I still have a problem.
> 
> I have created a new link type as you suggested and have consulted google
> on how to do it (my emacs-lisp-fu is not good enough to sort out directly what
> this function is doing ...). In my understanding the third argument is a function
> that is called when an export process has started and a link is about to be
> exported. My first problem is: this handler function is never called, the error
> message that i have inserted below does never appear. I have seen that the
> variable "org-link-types" contains the defined link type, and the variable
> "org-link-protocols" shows my handler.
> 
> My second problem is that the generated LaTeX output is
>   "\texttt{\cite{key}}"
> but it should simply be "\cite{key}". I would guess that the second problem
> is a corollary of the first one ...
> 
> Any ideas?
> 
> Andreas
> 

I'm pretty sure the second function is not quoted properly in your
org-add-link-type so it ends up actually getting called at the time of
the org-add-link-type is called.

Try the following:

--8<---------------cut here---------------start------------->8---
(defun rt-follow-handler (path)
  (message "dummy handler called, path = %s" path)
  (let ((arg (concat "\\cite{" path "}")))
    (reftex-view-crossref arg)))

(defun rt-export-handler  (path desc format)
  (message "my handler is called")
  (cond ((eq format 'latex)
	 (if (or (not desc) (equal 0 (search "rtcite:" desc)))
	     (format "\\cite{%s}" path)
	   (format "\\cite[%s]{%s}" desc path)))))

(require 'org)
(org-add-link-type "rtcite" 
		   (function rt-follow-handler)
		   (function rt-export-handler))
--8<---------------cut here---------------end--------------->8---

By way of explanation:

I had this as part of a minimal .emacs and it seems to work more or
less OK: I replaced the error call with a message call, because it
actually triggered and blew up :-) The rt-export-handler needs tweaking
but you 'll know what to do better than I do when you see the latex
output.

I had to (require 'org) to pick up the definition of org-add-link-type:
that seems to be a missing autoload somewhere.

And finally I like to quote functions with function, not quote, for
compiled-code reasons, but in most cases, it won't make any difference:
use quotes if you prefer.

Nick

> ============================================
> 
> (defun rt-handler (path)
>   (message "dummy handler called, path = %s" path)
>   (let ((arg (concat "\\cite{" path "}")))
>     (reftex-view-crossref arg)))
> 
> (org-add-link-type "rtcite" 
> 		   'rt-handler
> 		   (lambda (path desc format)
> 		     (error "my handler is called")
> 		     (cond ((eq format 'latex)
> 			    (if (or (not desc) (equal 0 (search "rtcite:" desc)))
> 				(format "\\cite{%s}" path)
> 			      (format "\\cite[%s]{%s}" desc path))))))
> 
> 
> ....


This email may be confidential and subject to legal privilege, it may
not reflect the views of the University of Canterbury, and it is not
guaranteed to be virus free. If you are not an intended recipient,
please notify the sender immediately and erase all copies of the message
and any attachments.

Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more
information.



This email may be confidential and subject to legal privilege, it may
not reflect the views of the University of Canterbury, and it is not
guaranteed to be virus free. If you are not an intended recipient,
please notify the sender immediately and erase all copies of the message
and any attachments.

Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more
information.

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

* Re: Integration of RefTeX and LaTeX export
  2012-02-17  8:10         ` Andreas Willig
@ 2012-02-17  8:36           ` Andreas Willig
  2012-02-17 17:59             ` Nick Dokos
  0 siblings, 1 reply; 11+ messages in thread
From: Andreas Willig @ 2012-02-17  8:36 UTC (permalink / raw)
  To: Andreas Willig; +Cc: nicholas.dokos, emacs-orgmode


Hi,

it is a version problem. I have just downloaded the latest version of
org-mode (7.8.03) and now the handler gets called. 

Sorry for the fuss ...

Thanks again, i really appreciate the quick help i have received here!!

Andreas

-----Original Message-----
From: Andreas Willig
Sent: Fri 2/17/2012 9:10 PM
To: Andreas Willig; nicholas.dokos@hp.com
Cc: nicholas.dokos@hp.com; emacs-orgmode@gnu.org
Subject: RE: [O] Integration of RefTeX and LaTeX export
 

I should have added that the rt-follow-hander is properly called ...

Is this a version problem?

-----Original Message-----
From: emacs-orgmode-bounces+andreas.willig=canterbury.ac.nz@gnu.org on behalf of Andreas Willig
Sent: Fri 2/17/2012 8:39 PM
To: nicholas.dokos@hp.com
Cc: nicholas.dokos@hp.com; emacs-orgmode@gnu.org
Subject: Re: [O] Integration of RefTeX and LaTeX export
 

Hi Nick,

thanks for this, but i cannot get it to work ...
I have started a vanilla emacs without any init file
(emacs -q), have loaded your snippet from a file and
evaluated the buffer. Again, the export-handler does
not get called. I am running Debian 6.0.4 and my emacs
is the one coming with it (see below).

I feel so stupid :-))

Andreas


M-x emacs-version says: GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version 2.20.0) of 2010-12-12 on raven, modified by Debian

M-x org-version says: Org-mode version 6.33x

Debian version is 6.0.4 (/etc/debian_version)



-----Original Message-----
From: Nick Dokos [mailto:nicholas.dokos@hp.com]
Sent: Fri 2/17/2012 6:31 PM
To: Andreas Willig
Cc: Thomas S.Dye; emacs-orgmode@gnu.org; nicholas.dokos@hp.com
Subject: Re: [O] Integration of RefTeX and LaTeX export
 
Andreas Willig <andreas.willig@canterbury.ac.nz> wrote:

> 
> Hi Thomas,
> 
> thanks for this hint. I have looked at this, the changed / added functions are
> below, everything else has not changed. I still have a problem.
> 
> I have created a new link type as you suggested and have consulted google
> on how to do it (my emacs-lisp-fu is not good enough to sort out directly what
> this function is doing ...). In my understanding the third argument is a function
> that is called when an export process has started and a link is about to be
> exported. My first problem is: this handler function is never called, the error
> message that i have inserted below does never appear. I have seen that the
> variable "org-link-types" contains the defined link type, and the variable
> "org-link-protocols" shows my handler.
> 
> My second problem is that the generated LaTeX output is
>   "\texttt{\cite{key}}"
> but it should simply be "\cite{key}". I would guess that the second problem
> is a corollary of the first one ...
> 
> Any ideas?
> 
> Andreas
> 

I'm pretty sure the second function is not quoted properly in your
org-add-link-type so it ends up actually getting called at the time of
the org-add-link-type is called.

Try the following:

--8<---------------cut here---------------start------------->8---
(defun rt-follow-handler (path)
  (message "dummy handler called, path = %s" path)
  (let ((arg (concat "\\cite{" path "}")))
    (reftex-view-crossref arg)))

(defun rt-export-handler  (path desc format)
  (message "my handler is called")
  (cond ((eq format 'latex)
	 (if (or (not desc) (equal 0 (search "rtcite:" desc)))
	     (format "\\cite{%s}" path)
	   (format "\\cite[%s]{%s}" desc path)))))

(require 'org)
(org-add-link-type "rtcite" 
		   (function rt-follow-handler)
		   (function rt-export-handler))
--8<---------------cut here---------------end--------------->8---

By way of explanation:

I had this as part of a minimal .emacs and it seems to work more or
less OK: I replaced the error call with a message call, because it
actually triggered and blew up :-) The rt-export-handler needs tweaking
but you 'll know what to do better than I do when you see the latex
output.

I had to (require 'org) to pick up the definition of org-add-link-type:
that seems to be a missing autoload somewhere.

And finally I like to quote functions with function, not quote, for
compiled-code reasons, but in most cases, it won't make any difference:
use quotes if you prefer.

Nick

> ============================================
> 
> (defun rt-handler (path)
>   (message "dummy handler called, path = %s" path)
>   (let ((arg (concat "\\cite{" path "}")))
>     (reftex-view-crossref arg)))
> 
> (org-add-link-type "rtcite" 
> 		   'rt-handler
> 		   (lambda (path desc format)
> 		     (error "my handler is called")
> 		     (cond ((eq format 'latex)
> 			    (if (or (not desc) (equal 0 (search "rtcite:" desc)))
> 				(format "\\cite{%s}" path)
> 			      (format "\\cite[%s]{%s}" desc path))))))
> 
> 
> ....


This email may be confidential and subject to legal privilege, it may
not reflect the views of the University of Canterbury, and it is not
guaranteed to be virus free. If you are not an intended recipient,
please notify the sender immediately and erase all copies of the message
and any attachments.

Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more
information.




This email may be confidential and subject to legal privilege, it may
not reflect the views of the University of Canterbury, and it is not
guaranteed to be virus free. If you are not an intended recipient,
please notify the sender immediately and erase all copies of the message
and any attachments.

Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more
information.

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

* Re: Integration of RefTeX and LaTeX export
  2012-02-17  8:36           ` Andreas Willig
@ 2012-02-17 17:59             ` Nick Dokos
  2012-02-17 19:12               ` Achim Gratz
  0 siblings, 1 reply; 11+ messages in thread
From: Nick Dokos @ 2012-02-17 17:59 UTC (permalink / raw)
  To: Andreas Willig; +Cc: nicholas.dokos, emacs-orgmode

Andreas Willig <andreas.willig@canterbury.ac.nz> wrote:


> it is a version problem. I have just downloaded the latest version of
> org-mode (7.8.03) and now the handler gets called.
> 

So what version were you using? The only likely fix I found was this
commit from almost two years ago:

,----
| commit 8a671f8d4da0066417d9dd78fffb42ea1fe9ec9d
| Author: Carsten Dominik <carsten.dominik@gmail.com>
| Date:   Wed May 12 15:14:17 2010 +0200
| 
|     LaTeX export: Use special formatting by link type interface
|     
|     Patch by Christian Moe, who writes:
|     
|     > It looks like support for formatting custom link types in LaTeX export
|     > is broken?
|     >
|     > I was trying to implement a custom link type with its own formatting
|     > function for HTML and LaTeX export, following the steps in
|     > org-bbdb.el.
|     >
|     > I've found that org-bbdb-export does not italicize bbdb links in
|     > LaTeX, nor does my own org-cite-export turn my custom =cite:= links
|     > into LaTeX =\cite{}= citations. Everything works fine in HTML export,
|     > but in LaTeX all custom link types get formatted as =\texttt{descr}=.
|     >
|     > I see that org-export-as-html and org-export-as-docbook look up
|     > org-link-protocols to get the function for formatting the link, but it
|     > seems that org-export-as-latex doesn't.
|     >
|     >
`----

and git describe says:

,----
| $ git describe 8a671f8d
| release_6.36-19-g8a671f8
`----

so yours must have been pre-6.36 or thereabouts, i.e. probably whatever was
built-in with your (23.2-based?) emacs.

If you were indeed using such an ancient version, I think you will be
*much* happier with latest.

> Sorry for the fuss ...
> 

No fuss, no muss.

Nick

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

* Re: Integration of RefTeX and LaTeX export
  2012-02-17 17:59             ` Nick Dokos
@ 2012-02-17 19:12               ` Achim Gratz
  2012-02-17 19:17                 ` Nick Dokos
  0 siblings, 1 reply; 11+ messages in thread
From: Achim Gratz @ 2012-02-17 19:12 UTC (permalink / raw)
  To: emacs-orgmode

Nick Dokos <nicholas.dokos@hp.com> writes:
> So what version were you using?

6.33 as delivered with Emacs23, this was buried in some earlier posting...


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Samples for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldSamplesExtra

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

* Re: Integration of RefTeX and LaTeX export
  2012-02-17 19:12               ` Achim Gratz
@ 2012-02-17 19:17                 ` Nick Dokos
  0 siblings, 0 replies; 11+ messages in thread
From: Nick Dokos @ 2012-02-17 19:17 UTC (permalink / raw)
  To: Achim Gratz; +Cc: nicholas.dokos, emacs-orgmode

Achim Gratz <Stromeko@nexgo.de> wrote:

> Nick Dokos <nicholas.dokos@hp.com> writes:
> > So what version were you using?
> 
> 6.33 as delivered with Emacs23, this was buried in some earlier posting...
> 

Thanks! I found the posting and it was a reply to me: hardly buried, but
I missed it nevertheless - sorry about that.

Nick

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

* Navigatable and exportable bib/notes links - Was: Re: Integration of RefTeX and LaTeX export
  2012-02-17  5:31     ` Nick Dokos
  2012-02-17  7:39       ` Andreas Willig
@ 2012-03-23 16:14       ` Olivier Berger
  1 sibling, 0 replies; 11+ messages in thread
From: Olivier Berger @ 2012-03-23 16:14 UTC (permalink / raw)
  To: emacs-orgmode

Hi.

FWIW, I've been inspired by your code and some other posts on the topic
of bibliographic references / notes management with org-mode and have
summarized the results in [0].

The end result : links like [[note:abibref]] or [[bib:abibref]] which
respectively point to a bibliography notes or a bibtex section in a
.bib, and which both can be exported to latex as regular \cite{abibref}
references would do.

Hope this helps.

Best regards,

[0] http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/

Nick Dokos <nicholas.dokos@hp.com> writes:

> I'm pretty sure the second function is not quoted properly in your
> org-add-link-type so it ends up actually getting called at the time of
> the org-add-link-type is called.
>
> Try the following:
>
>
>
> --8<---------------cut here---------------start------------->8---
> (defun rt-follow-handler (path)
>   (message "dummy handler called, path = %s" path)
>   (let ((arg (concat "\\cite{" path "}")))
>     (reftex-view-crossref arg)))
>
> (defun rt-export-handler  (path desc format)
>   (message "my handler is called")
>   (cond ((eq format 'latex)
> 	 (if (or (not desc) (equal 0 (search "rtcite:" desc)))
> 	     (format "\\cite{%s}" path)
> 	   (format "\\cite[%s]{%s}" desc path)))))
>
> (require 'org)
> (org-add-link-type "rtcite" 
> 		   (function rt-follow-handler)
> 		   (function rt-export-handler))
> --8<---------------cut here---------------end--------------->8---
>
>
>
> By way of explanation:
>
> I had this as part of a minimal .emacs and it seems to work more or
> less OK: I replaced the error call with a message call, because it
> actually triggered and blew up :-) The rt-export-handler needs tweaking
> but you 'll know what to do better than I do when you see the latex
> output.
>
> I had to (require 'org) to pick up the definition of org-add-link-type:
> that seems to be a missing autoload somewhere.
>
> And finally I like to quote functions with function, not quote, for
> compiled-code reasons, but in most cases, it won't make any difference:
> use quotes if you prefer.
>
> Nick
>

-- 
Olivier BERGER 
(OpenPGP: 4096R/7C5BB6A5)
http://www.olivierberger.com/weblog/

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

end of thread, other threads:[~2012-03-23 16:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-16 20:59 Integration of RefTeX and LaTeX export Andreas Willig
2012-02-16 22:08 ` Thomas S. Dye
2012-02-17  4:46   ` Andreas Willig
2012-02-17  5:31     ` Nick Dokos
2012-02-17  7:39       ` Andreas Willig
2012-02-17  8:10         ` Andreas Willig
2012-02-17  8:36           ` Andreas Willig
2012-02-17 17:59             ` Nick Dokos
2012-02-17 19:12               ` Achim Gratz
2012-02-17 19:17                 ` Nick Dokos
2012-03-23 16:14       ` Navigatable and exportable bib/notes links - Was: " Olivier Berger

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