About this site / and more

Table of Contents

This site is generated by Jekyll (3.5.1), using org-mode (9.0.3) with ox-jekyll (included in the org-octopress org-octopress emacs package). The theme derives from the so-simple-theme.

1. emacs Customization

From ox-jekyll, I redefined the function "org-jekyll-insert-export-options-template" as post this way

(defun post
  (&optional title date setupfile categories tags published layout)
  "Insert a settings template for Jekyll exporter."
  (let ((layout     (or layout org-jekyll-layout))
        (published  (or published org-jekyll-published))
        (tags       (or tags org-jekyll-tags))
        (categories (or categories org-jekyll-categories)))
      (insert (format (concat
                       "#+TITLE: "             title
                       "\n#+DATE: "              date
                       "\n#+SETUPFILE: "         setupfile
                       "\n#+JEKYLL_LAYOUT: "     layout
                       "\n#+JEKYLL_CATEGORIES: " categories
                       "\n#+JEKYLL_TAGS: "       tags
                       "\n#+JEKYLL_PUBLISHED: "  published
                       "\n\n* \n\n"))))))

2. Editing and exporting Tricks

2.1. Edition

2.1.1. The date of today

{ { { time(%Y-%m-%d %a %H:%M) } } }

Just remove space between brackets

2.1.2. Verbatim

Start a line with ": "

: Verbatim line 

2.1.3. No export

To skip a sub-tree entry from export, just add the tag noexport.

2.1.4. Templates

To insert template, for instance


just type

<s C-i (or tab, M-tab)

The full list of built-in template are here. You need for these shortcut the org-tempo module.

s 	#+BEGIN_SRC ... #+END_SRC
l 	#+BEGIN_LaTeX ... #+END_LaTeX
L 	#+LaTeX:
H 	#+HTML:
i 	#+INDEX: line
I 	#+INCLUDE: line 

2.1.5. TOC

  • If you want to remove the table of contents, just add in the header:
#+OPTIONS: toc:nil

See this page for more details about table of contents and settings.

  • If you want to disable numbering of headings, add :
#+options: num:nil
  • If you want place the TOC where you want :

First remove it from option

#+OPTIONS: toc:nil

Then add it like that where you want:

#+TOC: headlines 1

2.1.6. Images

  • To insert image, I just insert html code:
<img src="/assets/figs/gauss_err.png" alt="bla" style="width:400px; margin:0px auto;display:block"/>

And the image is stored in a subdir of assets.


3. Exporting issue

Try to reload orgmode:

C-c C-x !

Or this solution sometimes:

C-U M-x org-reload

4. Publishing

In the .emacs file I added the following code:

(setq org-publish-project-alist

          ;; Path to your org files.
          :base-directory "~/Sites/org/homepages"
          :base-extension "org"

          ;; Path to your Jekyll project.
          :publishing-directory "~/Sites/jekyll/homepages"
          :recursive t
          :publishing-function org-jekyll-publish-to-html
          :headline-levels 4 
          :html-extension "html"

          :base-directory "~/Sites/org/homepages"
          :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|php"
          :publishing-directory "~/Sites/jekyll"
          :recursive t
          :publishing-function org-publish-attachment)

    ("aa" :components ("org-alex" "org-static-alex"))


Then just type :

C-c-e P x aa (where aa is the project name)

The code is derived from org-jekyll page.

Then just another shortcut :

(defun sdf
"Insert a settings template for Jekyll exporter."
(org-publish-project "aa" )
(compile "cd ~/Sites/jekyll/homepages; bundle exec jekyll build; ")

5. Latex

5.1. Equation

To use MathJax to export latex equation just add the following option:

#+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler

Then you can write (and get) things like that:

\begin{equation} x=\sqrt{b} \ \end{equation}

5.2. Latex definition (for both html/jekyll and latex export)

To use some latex definition (i.e newcommand, or def), you can download the file define.setup from this repository and then follow the instruction. This solution worked fine for me until recently (and a change + update of emacs,org, … messy things). And I did not find the solution to make it work again.

The more recent solution is to use a file (defmath.org somewhere) with your definitions written like this:

@@html:<div style="display: none">@@

The solution comes from one answer on this stackoverflow question. There are maybe better solutions. But this one works for me.

6. Bibtex

There are some steps to follow if you want to use bibtex references in an org file for a further export.

6.1. The "pdf to latex" process

First in you dot emacs file :

(setq org-latex-pdf-process (list "latexmk -pdf %f"))

You can us another tool than latexmf but it is more convenient since it deals with the compilation of bibtex files. But if you really want to go back to bibtex:

(setq org-latex-pdf-process
      '("pdflatex -interaction nonstopmode -output-directory %o %f"
        "bibtex %b"
        "pdflatex -interaction nonstopmode -output-directory %o %f"
        "pdflatex -interaction nonstopmode -output-directory %o %f"))

6.2. in your orgfile

Start with the header:

#+LATEX_HEADER: \usepackage[natbib=true]{biblatex} \DeclareFieldFormat{apacase}{#1} \addbibresource{/path/my_refs.bib}

Then add a block anywhere you want in the orgfile :#+beginsrc bibtex :exports none :tangle "/path/myrefs.bib" :@article{Blei03LDA, : Author = {Blei, D. M. and Ng, A. Y. and Jordan, M. I.}, : Journal = {Journal of Machine Learning Research}, : Pages = {993–1022}, : Title = {Latent dirichlet allocation}, : Volume = {3}, : Year = {2003}} #:+endsrc

the important points:

  • :exports none: does not export the block of code, so it won't appear in the latex and pdf files
  • :tangle: "/path/myrefs.bib": when we will use tangle to extract the bibtex entry, it will be written in the specified file.

6.3. export

To export the file, we need to first to tangle the bibtex entries:

C-c C-v t

Then run the latex export

C-c C-e l p 

The first step is only required when you add/remove/modify the bibtex entries.

7. Setting the path : find the right latex and other useful tools

Add in the .emacs file:

;; to find the right latex install 
(defun set-exec-path-from-shell-PATH ()
  "Sets the exec-path to the same value used by the user shell"
  (let ((path-from-shell
          "[[:space:]\n]*$" ""
          (shell-command-to-string "$SHELL -l -c 'echo $PATH'"))))
    (setenv "PATH" path-from-shell)
    (setq exec-path (split-string path-from-shell path-separator))))


8. Examples

Date: 2024-06-24 lun. 17:13

Author: A. Allauzen

Created: 2024-06-24 lun. 17:13