Created
December 20, 2021 08:29
-
-
Save even4void/3fee4264b29cfcb28ac001a1e2ad4c47 to your computer and use it in GitHub Desktop.
org-babel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; org-babel.el --- default settings for org->pdf compilation | |
;;; | |
;;; Commentary: | |
;;; This is very basic stuff. | |
;;; | |
;;; Code: | |
(require 'org) | |
(add-to-list 'load-path "/home/chl/Documents/notes") | |
(require 'ox-bibtex) | |
(org-babel-do-load-languages | |
'org-babel-load-languages | |
'((R . t) | |
(python . t))) | |
(setq TeX-engine 'luatex) | |
(setq inferior-R-program-name "/usr/bin/R" | |
inferior-R-args "-q --no-save --no-restore") | |
(setq org-bibtex-file "/home/chl/Documents/notes/references.bib" | |
org-confirm-babel-evaluate nil | |
org-export-with-author nil | |
org-export-with-creator nil | |
org-export-with-toc nil | |
org-export-with-section-numbers nil | |
org-html-postamble "Generated by %c on %T (%e)" | |
org-html-htmlize-output-type nil | |
org-html-doctype "html5" | |
org-html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"/home/chl/Documents/notes/.assets/worg.css\" />" | |
org-html-head-include-default-style nil | |
org-html-head-include-scripts nil | |
org-latex-default-class "tufte-handout" | |
org-latex-pdf-process '("latexmk -pdf -bibtex-cond -f -outdir=%o %f")) | |
(eval-after-load "ox-latex" | |
'(add-to-list 'org-latex-classes | |
'("tufte-handout" | |
"\\documentclass[nobib]{tufte-handout} | |
\\usepackage[backend=bibtex,style=numeric-comp,citestyle=numeric-comp,autocite=plain]{biblatex} | |
\\addbibresource{/home/chl/Documents/notes/references.bib} | |
\\usepackage{booktabs} | |
% little HACK for tabular only environment | |
\\setlength{\\doublerulesep}{\\arrayrulewidth} | |
\\let\\tbl\\tabular | |
\\def\\tabular{\\sffamily\\small\\tbl} | |
\\usepackage{graphicx} | |
\\usepackage{microtype} | |
\\usepackage{hyphenat} | |
\\usepackage{marginfix} | |
\\usepackage{amsmath} | |
\\usepackage{morefloats} | |
\\usepackage{fancyvrb} | |
\\fvset{fontsize=\\normalsize} | |
\\usepackage{xspace} | |
\\usepackage{nicefrac} | |
\\usepackage{units} | |
\\usepackage{soul} | |
\\usepackage{xcolor} | |
\\usepackage{hyperref} | |
\\hypersetup{colorlinks,allcolors=darkgray} | |
\\makeatletter | |
\\patchcmd{\\hyper@link@} | |
{{\\Hy@tempb}{#4}} | |
{{\\Hy@tempb}{\\ul{#4}}} | |
{}{} | |
\\makeatother | |
[NO-DEFAULT-PACKAGES] | |
[EXTRA]" | |
("\\section{%s}" . "\\section*{%s}") | |
("\\subsection{%s}" . "\\subsection*{%s}") | |
("\\subsubsection{%s}" . "\\subsubsection*{%s}") | |
("\\paragraph{%s}" . "\\paragraph*{%s}") | |
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))) | |
(eval-after-load "ox-latex" | |
'(add-to-list 'org-latex-packages-alist | |
'("AUTO" "babel" t ("pdflatex")))) | |
(eval-after-load "ox-latex" | |
'(add-to-list 'org-latex-packages-alist | |
'("AUTO" "polyglossia" t ("xelatex" "lualatex")))) | |
(eval-after-load "ox-latex" | |
'(add-to-list 'org-latex-packages-alist '("autostyle=true" "csquotes"))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
OPT=$1 | |
FILE=$2 | |
case $OPT in | |
-pdf) | |
emacs --batch -l /home/chl/Documents/notes/org-babel.el --eval "(progn (find-file \"$FILE\") (org-latex-export-to-pdf))" | |
;; | |
-html) | |
rc="$(grep '#+BIBLIOGRAPHY' $FILE)" | |
[ -z $rc ] && echo "\033[1mNo valid bibliography found.\033[0m" | |
emacs --batch -l /home/chl/Documents/notes/org-babel.el --eval "(progn (find-file \"$FILE\") (org-html-export-to-html))" | |
;; | |
*) | |
echo "Unknown export format." | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Minimal config to create Tufte handout in PDF from Org files. In order to use this stuff, put the Bash script in a directory that's in your
$PATH
, and invoke it as, e.g.,org-babel.sh -pdf yourfile.org
. It requires two additional files: (1) the fileorg-babel.el
(mandatory), which provides all the default settings for Emacs, and (2) a Bibtex file (optional), where bibliographic entries are stored.Note that Emacs
load-path
,org-bibtex-file
andbibresource
must reflect the correct pathnames on your file system; the same applies for the Bash script.