Re: [O] exporting α/β to latex/pdf

2014-05-07 Thread Clément B.

But that's not quite right: you end up with a circular definition (and
both pdflatex and plain latex think so: they infloop).

One way to fix it using a math alpha:

--8---cut here---start-8---
#+LATEX_HEADER: \DeclareUnicodeCharacter{03b1}{\(\alpha\)}
--8---cut here---end---8---



Oh my ! You are right of course. Sorry if I misled anybody.


Clément





Re: [O] exporting α/β to latex/pdf

2014-05-05 Thread Clément B.

The *easiest* solution is to just say \alpha and \beta in the org file
instead of α and β. But biting the bullet and adopting XeTeX or LuaTeX is
probably the *best* way to go (he says without ever having used either...)


For those who stick with pdflatex, you can also use α directly in the 
org document, and define


#+latex_header: \usepackage[utf8]{inputenc}
#+latex_header: \declareunicodecharacter{03b1}{α}

Provided your file is indeed encoded in utf-8 (but why would you use any 
other encoding?)


This simply tells the compiler to bind α to the unicode character 
greek small letter alpha (U+03B1). If there is a lot of unicode in the 
document, XeTeX/LuaTeX are definitely better choices.



Clément





Re: [O] Keeping up to date

2014-04-30 Thread Clément B.

Hi everyone,


So, yes, that's a bit of a headache
as well and I think if you are doing a bunch with extra Emacs add-ons,
it would be worth syncing.


Rather than Dropbox, you could use a version control system. My entire 
.emacs.d is under git control, I can try out a library, and if I like 
it, check it in. That way, I don't really care if my elisp directory is 
dirty, I only take home what I like.


Now, that works well for lonely .el files. Two problems arise if :

1. The library is a clone of another git repository (like org)

2. The library comes from melpa (also like org)

For the first one, technically, you could checkout org git repository 
inside your .emacs, and manage it as a submodule, but they are a huge 
pain. If you pull it out you can keep everything in sync though, and 
still be able to play around with org branches.


For the second one, melpa packages change too often to make it practical 
to check them in. One solution is use cask, as recommended by Grant, the 
other one (a bit more simplistic), is to make sure that the library is 
installed on every box you use, so the sync happens at the (m)elpa 
level. I have the following code in my init.el (it comes from emacs 
prelude I think) :


  (require 'cl)

  (package-initialize)
  (add-to-list 'package-archives
   '(melpa . http://melpa.milkbox.net/packages/;))
  (unless package-archive-contents
(package-refresh-contents)

  (defvar my-packages
  '(org auctex ess)
  A list of packages to ensure are installed at launch.)

(dolist (pack my-packages)
  (when (not (package-installed-p pack))
(package-install pack)


This makes sure org from melpa is installed when emacs starts. It 
doesn't check whether it's the last version though.



Clément



Re: [O] State of the art in citations

2014-04-27 Thread Clément B .
Hi Leonard,

 I am in the process of writing a new package for inserting
 citations into org buffers using RefTeX.

I'd be interested to know what you have in mind. I use something
of the sort, by customising `reftex-cite-format`, e.g:

(setq reftex-cite-format
   '((?\C-m . \\cite[]{%l})
 (?b . [[ref:%l][%A (%y)]])))

This makes inserting custom links (ref) easier with the usual
`reftex-citation` bound to C-c [.


 On the other hand, it will work with multicite commands,
 whereas Clement's does not look like it will.

It does not, and that's a big limitation. That being said, I don't
know how to go about mixing multiple citations and links to the
bib file. This is definitely something I care about, being able
to quickly jump from the text to the bibliographic entry, PDF
file, or whatever source I am using to write is one of the main
reasons I use org instead of plain LaTeX.


Bye,

Clément



Re: [O] State of the art in citations

2014-04-27 Thread Clément B .
Hi Ken,

 When I export this to LaTeX, it is not treated as a proper
 LaTeX citation. The text is just the %A (%y) part. Is there
 some way to export so that the ref:%l turns into a \cite{%l}?

The ref is a custom link type, you can define those in org with
`org-add-link-type`, and they allow control over the export
behaviour. See the previous posts in this thread for an example.

Bye,

Clément



Re: [O] State of the art in citations

2014-04-27 Thread Clément B .

 I find the best way to support ODT is simply add something like this:

   ((eq format 'odt)
(format (%s) desc))

 This doesn't create a bibliography section, but that section is awkward
 to export to anyway. It requires the 3rd party Org hack that isn't
 officially supported, java, jabref, is awfully slow (~2
 seconds/reference), etc. I now put the references inline as above, and
 then manually add the references by exporting to PDF and copying/paste
 that reference section. 

 Not great, but less of a hack than ODT-supported references, and working
 with ODT/Word is a hack anyway.

I came to a similar conclusion for html export, it is very hard
to match bibtex/biblatex to produce a proper bibliography, so one
might as well use it. At one point, the thought of writing a
custom citation style that would output html code crossed my mind
(I think biblatex would allow that), but I just don't use html
export enough. Although if this is possible, it could work with
xml for odt as well.

 Still looking into lastname (Year) format...

I hadn't noticed that before, but now that you mention it, I
think this is related to the way you format your bib file.

For example %A (%y) with:

1. name = {Darwin, Charles}
   year = {1859}

   will yield Darwin (1859)


2. name = {Charles Darwin}
   year = {1859}

   will yield Charles Darwin (1859)

Not very consistent. This might be something to take to the
AUCTeX guys.



Re: [O] State of the art in citations

2014-04-27 Thread Clément B .

 It appears to work for multicite for me. Or at least well enough. If I
 select multiple entries, I get this:

 [[ref:Author1:,Author2:,Author3:][()]]

 I can then easily insert the text I want into the (). It exports
 properly to LaTeX as \cite{Author1:,Author2:,Author3:}.

 Maybe most people multi-cite more than me, but I think it is only a bit
 of extra work to add what I want in the () and then it exports properly
 to LaTeX and, using the references-via-LaTeX, to ODT/HTML too!

   -k.

The problem is that you can't link to a bibtex entry,
[[ref:Author1:,Author2:]] is not picked up by org search
function of `org-open-file`. And even if it was, it couldn't link
to several entries at once. So to preserve the ability to jump
quickly to a reference, I quite like the export filter approach,
which I was unaware of (thank you Thomas! ).


Clément



Re: [O] State of the art in citations

2014-04-27 Thread Clément B .
Hi John,

This is great ! Way more advanced than anything I have said.

 2. Clickable cite links. If you have a citation link like
 cite:key1,key2,key3 you can click on key1 and open the bibliography file to
 key1, and you can click on key2 and have it open at key 2. This link would
 export in latex as \cite{key1,key2,key3}. Other cite formats, e.g. citep,
 citep*, etc... are defined too, but are relatively untested. You can also
 use completion to enter a bibtex key.

This was my main concern, glad to see you can treat the different
parts of the links as separate citations, and access their
respective bibtex entry. The completion is very handy too.

 9. variables to point to a notes file and pdf directory, and functions to
 jump to your notes and the pdf file from a bibtex entry.

I use something similar, but only for the pdf file. I think the
open-in-browser function is implemented in the latest bibtex-mode
(`bibtex-url` bound to C-c C-l).

Bye,

Clément



Re: [O] State of the art in citations

2014-04-26 Thread Clément B .

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



Re: [O] State of the art in citations

2014-04-26 Thread Clément B .
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