emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Clément B." <clement@inventati.org>
To: julian@hafro.is
Cc: emacs-orgmode@gnu.org
Subject: Re: State of the art in citations
Date: Sat, 26 Apr 2014 18:56:21 +0200	[thread overview]
Message-ID: <87ppk4ni6i.fsf@gaillac.origami> (raw)

Hi all,

> - Should I use biblatex instead of bibtex?  

You should. It is very powerful and straightforward. The manual
is great.


As for citations, I find that the most flexible way is to define
my own link types, that allows control on both org formatting and
export

Let's say for example that you want to cite an entry of your .bib
file, which key is Chiles:2012:Geostatistics. Something like :

see Chilès 2012, p.145

Note (i) the "see" (ii) the "p.145", they are both part of the
citation. In this case, biblatex provides the following command

\cite[see][p.145]{Chiles:2012:Geostatistics}


For readability purposes, the citation should appear as is in the
org file, the "\cite{Chiles:2012:Geostatistics}" command should
only appear when exporting to LaTeX. Furthermore, this should be
a link to the entry in the .bib file, so the complete org link
would look like

[[ref:Chiles:2012:Geostatistics][(see for example Chilès 2012, p.145)]]

Where ref is a custom link type to the said bib file.

To do that, I have defined the following link-type in my init.el :

(org-add-link-type                       
 "ref"
 (lambda (key)
   (org-open-file cby-references-file t nil key))
 (lambda (path desc format)
   (cond
    ((eq format 'html)
     (format "(<cite>%s</cite>)" path))
    ((eq format 'latex)
     (let* ((postnote (cby-org-link-get-postnote desc))
            (prenote (cby-org-link-get-prenote desc)))
       (cond
        ((and prenote postnote)
         (format "\\cite[%s][%s]{%s}" prenote postnote path))              
        (postnote
         (format "\\cite[%s]{%s}" postnote path))
        (prenote
         (format "\\cite[%s][]{%s}" prenote path))
        (t
         (format "\\cite{%s}" path))))))))

Some remarks :

1. `cby-references-file` is my master .bib file.

2. The html export is rather rudimentary, it simply takes the org
   link description (%s) and puts it between <cite> markups.

3. To get the prenote (the "see") and postnote (the "p.145"), I
   use very shaky functions (`cby-org-link-get-postnote`) that
   strip the link description. I haven't come up with a proper
   solution yet so here is one for reference :

   (defun cby-org-link-get-postnote (desc)
     "Extract postnote from org-mode link description. Postnote
      starts at last ',' and ends at last ')'."
     (let ((postnote (cadr (split-string desc "[,)]"))))
       (if postnote
           (copy-sequence
            ;; clean string
            (replace-regexp-in-string "[ \t\n]" "" postnote)))))


4. To use the wide range of commands provided by biblatex, I also
   have a "pref" link type that exports to "\parencite{}" and a
   "tref" type that exports to "\texcite{}"

This is all work in progress, but custom link types make both
your org source file readable and export flexible.


> I use org-mode to write scientific papers, exporting mostly to LaTex/pdf
> (and sometimes to Word via ODT when I have to collaborate with less
> enlightened colleagues)

I also tried to do that, but do you have a way to get odt files
back to org ? I saw a package for that somewhere.


Bye,


Clément

             reply	other threads:[~2014-04-26 16:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-26 16:56 Clément B. [this message]
2014-04-27 13:08 ` State of the art in citations Leonard Randall
2014-04-27 14:14   ` Clément B.
2014-04-27 14:41     ` Ken Mankoff
2014-04-27 16:01     ` Thomas S. Dye
2014-04-27 16:16       ` Ken Mankoff
2014-04-27 16:57         ` Clément B.
2014-04-27 19:20           ` John Kitchin
2014-04-27 21:30             ` Clément B.
2014-04-28 13:57             ` Julian M. Burgos
2014-04-28 13:56   ` Julian M. Burgos
2014-04-29  9:30 ` Vikas Rawal Lists
2014-04-29 15:36   ` Richard Lawrence
2014-04-29  9:30 ` Vikas Rawal Lists
  -- strict thread matches above, loose matches on Subject: below --
2014-04-27 14:53 Clément B.
2014-04-27 15:26 ` Ken Mankoff
2014-04-27 16:05   ` Clément B.
2014-04-27 16:10     ` Ken Mankoff
2014-04-26 18:26 Clément B.
2014-04-28  1:53 ` Richard Lawrence
2014-04-25 12:11 Julian M. Burgos
2014-04-25 15:42 ` Grant Rettke

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=87ppk4ni6i.fsf@gaillac.origami \
    --to=clement@inventati.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=julian@hafro.is \
    /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).