emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Andreas Willig <andreas.willig@canterbury.ac.nz>
To: "Thomas S.Dye" <tsd@tsdye.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Integration of RefTeX and LaTeX export
Date: Fri, 17 Feb 2012 17:46:28 +1300	[thread overview]
Message-ID: <24B979D4-6B28-4521-92F5-AED136335FB0@canterbury.ac.nz> (raw)
In-Reply-To: <m1r4xuo2id.fsf@tsdye.com>


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.

  reply	other threads:[~2012-02-17  4:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=24B979D4-6B28-4521-92F5-AED136335FB0@canterbury.ac.nz \
    --to=andreas.willig@canterbury.ac.nz \
    --cc=emacs-orgmode@gnu.org \
    --cc=tsd@tsdye.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).