# An archi-minimal test of bibliography export. # Goals : export to LaTeX(PDF) and DOCX as transparently as possible #+options: tex:t title:nil author:nil date:nil toc:nil #+property: header-args:sage :session #+PANDOC_OPTIONS: number-sections:t #+begin_src emacs-lisp :exports none :results none (require 'org-ref) ;; This is much needed to manage changes in bibliography exports... (setq org-latex-pdf-process (list "latexmk -pdf -pdflatex='%latex -interaction=nonstopmode -shell-escape' -bibtex -f %f") org-latex-to-mathml-convert-command "latexmlmath \"%i\" --presentationmathml=%o") #+end_src Export by **src_emacs-lisp[:results raw]{org-export-current-backend}**. * Test of maths <> ** Hand-typed Everyone knows[fn::or should know...] that \(e^{i\theta}=\cos\theta+i\sin\theta\)[fn::This is de Moivre's formula]. It results that: #+name: eq:Euler \begin{equation} e^{i\pi}+1=0 \end{equation} This equation [[eq:Euler]], known as Euler's formula, is one of the best known formulas of elementary maths. ** Sage-generated #+name: FA #+begin_src sage :exports results :results table def matable(): a,b=SR.var("a, b") LF=[sin, cos, tan] T=[f(v)==f(v).trig_expand() for f in LF for v in[a+b, a-b]] return [[r"\(\displaystyle {}\)".format(latex(f))] for f in T] matable() #+end_src #+name: tab:FA #+caption:Addition formulas, générated by the Sage snippet [[lst:FA]]. #+RESULTS: FA | \(\displaystyle \sin\left(a + b\right) = \cos\left(b\right) \sin\left(a\right) + \cos\left(a\right) \sin\left(b\right)\) | | \(\displaystyle \sin\left(a - b\right) = \cos\left(b\right) \sin\left(a\right) - \cos\left(a\right) \sin\left(b\right)\) | | \(\displaystyle \cos\left(a + b\right) = \cos\left(a\right) \cos\left(b\right) - \sin\left(a\right) \sin\left(b\right)\) | | \(\displaystyle \cos\left(a - b\right) = \cos\left(a\right) \cos\left(b\right) + \sin\left(a\right) \sin\left(b\right)\) | | \(\displaystyle \tan\left(a + b\right) = -\frac{\tan\left(a\right) + \tan\left(b\right)}{\tan\left(a\right) \tan\left(b\right) - 1}\) | | \(\displaystyle \tan\left(a - b\right) = \frac{\tan\left(a\right) - \tan\left(b\right)}{\tan\left(a\right) \tan\left(b\right) + 1}\) | The results in table [[tab:FA]] (generated by the Sage snippet in listing [[lst:FA]]) should be known perfectly by any college candidate (yes, even in humanities...). * Figures <> #+name: SageFig #+begin_src sage :results file :exports results plot(sin, -pi,pi, figsize=4, aspect_ratio=1) #+end_src #+name: fig:SageFig #+caption: A well-known figure, generated by the Sage snippet ||lst:SageFig]]. #+RESULTS: SageFig [[file:/home/charpent/.sage/temp/zen-book-flip/1793/tmp_ptu96N.png]] The figure [[fig:SageFig]] (generated by the code snippet of listing [[lst:SageFig]]) whil be placed by \LaTeX at some ``convenient'' place. * Citations <> # This has been created with ~org-ref-help-insert-cite-link~, # at a time where the ~[[bibliography...~ link was uncommented. Citation attempt with a ~cite:~ link : cite:chenouardPhoneTriagePaediatric2016,bergouniouxCalpainActivationShigella2012 # This has been created with ~org-ref-tex-citation : Another attempt, using a ~\cite{}~ \LaTeX{} macro : \cite{loganadaneCurrentRoleWhole2017} * Conclusions ** What works * Maths (inline, displayed or math environments) are correctly displayed. There is some support for referencing (isolated) equations. See §[[sec:Maths]]. * Tables are correctly displayed and referenced. (Ditto). * Figures are correctly displayed and referenced. See §[[sec:Figures]] * Citations can be correctly retrieved and bibliographies can be correctly generated, as shown in §[[sec:Citations]]. The latter requires some ingenuity: My source contains the following snippet at the place where the references are needed: #+begin_src emacs-lisp :eval no :exports code :noweb yes <> #+end_src The resulting trick leaves enough information in the source file to be able to use ~org-reftex-citation~ function (~C-c C-x [~) but not enough for the ~org-ref-helm-insert-cite-link~ (~C-c ]~). One also notes that the ~:results~ type **has** to be ~raw~ ; using ~org~ prepends a comma to the intended result... ** What doesn't (in any exporter) * Links are not expanded in captions, and print litteraly. A test show that ~org-ref~ ~ref:~ links do expand in captions when exported by the native \LaTeX{} exporter. They are, however, unusable for my purpose, since they do not export (i.e. print litteraly) to anything else... ** Support depending on the exporter *** Built-in \LaTeX{} exporter * Listings (code snippets) are numbered and labeled as figures. *** All ~pandoc~ exporters * References appear necessarily at the end of the document. I understand that this a long-known deficiency of ~pandoc~; some workaround exist for ~HTML~ output, but do not seem to apply to ~.docx~ nor ~.pdf~ outputs. *** ~Pandoc~ \LaTeX{} exporter (~ox-pandoc~) * Code snippets are correcly numbered, but neither their captions nor the numbers appear in the resulting PDF. * (A pecadillo) In text, the string =\LaTeX{}= exports literally as ~LaTeX{}~, not the expected symbol... *** ~Pandoc~ ~.docx~ exporter * I have been unable to get numbered sections. I understand that this might be a limitatin of ~pandoc~ itself, and can be fixed by substituting another ~.docx~ template. * I have been unable to master the position of some elements: both table and figures appear at the left of the page. \appendix * Some listings ** Maths #+name: lst:FA #+caption: Generation of table [[tab:FA]] #+begin_src sage :eval no :exports code :noweb yes <> #+end_src ** Figures #+name: lst:SageFig #+caption: Generation of the figure [[fig:SageFig]]. #+begin_src sage :eval no :exports code :noweb yes <> #+end_src #+name: BiblioTrick #+begin_src emacs-lisp :exports results :results raw (cond ( ;; This allows export to DOCX/ODT : (eq org-export-current-backend 'pandoc) "* References\n\#+bibliography: CRCInnovation2019.bib\n\#+PANDOC_OPTIONS: csl:vancouver-brackets.csl") ;;This allows export to LaTeX/PDF with the builtin exporter : ((eq org-export-current-backend 'latex) "[[bibliographystyle:vancouver]]\n[[bibliography:CRCInnovation2019.bib]]") ;; This leaves enough information to allow org-reftex to find its file : (t "\#+bibliography: CRCInnovation2019")) #+end_src #+RESULTS: #+bibliography: CRCInnovation2019