#+startup: beamer #+TITLE: Using org-mode for scientific posters * Preamble :ignore: ** General comments :ignore: # ---------------------------------------------------------------------- # - Turn on synonyms by starting synosaurus-mode # - Look up words using C-c sr # - Turn on dictionary by starting flyspell-mode # - Count words by section using org-wc-display # ---------------------------------------------------------------------- ** Specific comments for this manuscript :ignore: # ---------------------------------------------------------------------- # This is a comment # ---------------------------------------------------------------------- ** org specific settings :ignore: # ---------------------------------------------------------------------- #+OPTIONS: email:nil toc:nil num:nil author:nil date:t tex:t title:nil #+STARTUP: align fold #+SEQ_TODO: TODO(t) | DONE(d) #+TAGS: figure(f) check(c) noexport(n) ignore(i) #+LANGUAGE: en #+EXCLUDE_TAGS: noexport TODO #+DATE: {{{time(%Y-%m-%d %H:%M)}}} # ---------------------------------------------------------------------- ** Latex header :ignore: # ---------------------------------------------------------------------- #+LATEX_CLASS: mybeamerposter #+LATEX_HEADER: \setlength{\paperwidth}{36in} #+LATEX_HEADER: \setlength{\paperheight}{48in} #+LATEX_HEADER: \setlength{\textwidth}{0.98\paperwidth} #+LATEX_HEADER: \setlength{\textheight}{0.98\paperheight} #+LATEX_HEADER: \graphicspath{{../output/figures/}{../lib/}} #+LATEX_HEADER: \usepackage[export]{adjustbox} #+LATEX_HEADER: \usepackage{graphicx,caption} #+LATEX_HEADER: \usepackage{minted} #+LATEX_HEADER: \usepackage{eurosym} #+LATEX_HEADER: \usepackage{listings} #+LATEX_HEADER: \usepackage{textcomp} #+LATEX_HEADER: \usepackage{bibentry} #+LATEX_HEADER: \newcommand\sumin{\sum_{i=1}^{n}} #+LATEX_HEADER: \newcommand{\Xoi}[1]{#1(i)} #+LATEX_HEADER: \newcommand{\frakPQ}[2]{\frac{\Xoi{#1}}{\Xoi{#2}}} #+LATEX_HEADER: \newcommand{\DKLPQ}[3]{D_{\mathrm{KL}}(#1 #3 #2)} #+LATEX_HEADER: \date{} # ---------------------------------------------------------------------- ** Latex macros :ignore: # ---------------------------------------------------------------------- #+LATEX_HEADER: \newcommand{\auth}{Philipp Homan, MD, PhD} #+LATEX_HEADER: \newcommand{\authemail}{phoman1@northwell.edu} #+LATEX_HEADER: \newcommand{\authtwitter}{@philipphoman} #+LATEX_HEADER: \newcommand{\authgithub}{github.com/philipphoman} # ---------------------------------------------------------------------- ** Authors and affiliations :ignore: # ---------------------------------------------------------------------- #+LATEX_HEADER: \author{ #+LATEX_HEADER: Philipp Homan$^{1}$ #+LATEX_HEADER: \\ #+LATEX_HEADER: \normalsize{$^{1}$Department of Psychiatry,} #+LATEX_HEADER: \normalsize{The Donald and Barbara Zucker} #+LATEX_HEADER: \normalsize{School of Medicine at Northwell/Hofstra,} #+LATEX_HEADER: \normalsize{Hempstead, NY} #+LATEX_HEADER: } # ---------------------------------------------------------------------- ** Buffer-wide source code blocks :ignore: # ---------------------------------------------------------------------- # Set elisp variables need for nice formatting We want no new lines in # inline results and a paragraph size of 80 characters Important: this # has to be evaluated witch C-c C-c in order to work in the current # buffer #+BEGIN_SRC emacs-lisp :exports none :results silent ; Nicer formatting for code (setq org-latex-listings t) (setq org-latex-listings 'minted) '(org-export-latex-listings-langs (quote ((emacs-lisp "Lisp") (lisp "Lisp") (clojure "Lisp") (c "C") (cc "C++") (fortran "fortran") (perl "Perl") (cperl "Perl") (python "Python") (ruby "Ruby") (html "HTML") (xml "XML") (tex "TeX") (latex "TeX") (shell-script "bash") (gnuplot "Gnuplot") (ocaml "Caml") (caml "Caml") (sql "SQL") (sqlite "sql") (R-mode "R")))) (setq org-latex-minted-options '(("linenos=true") ("bgcolor=lightgray"))) ; set timestamp format ;(setq org-export-date-timestamp-format "%FT%T%z") (require 'org-wc) (flyspell-mode t) ;(evil-declare-change-repeat 'company-complete) (setq synosaurus-choose-method 'popup) (synosaurus-mode t) (auto-complete-mode t) ;(ac-config-default) ;(add-to-list 'ac-modes 'org-mode) (linum-mode t) (whitespace-mode t) (setq org-babel-inline-result-wrap "%s") (setq org-export-with-broken-links "mark") (setq fill-column 72) (setq whitespace-line-column 72) ;(setq org-latex-caption-above '(table image)) (setq org-latex-caption-above nil) (org-toggle-link-display) ; don't remove logfiles at export (setq org-latex-remove-logfiles nil) ; Keybindings ; (global-set-key (kbd " c") "#+CAPTION: ") (defun setfillcolumn72 () (interactive) (setq fill-column 72) ) (defun setfillcolumn42 () (interactive) (setq fill-column 42) ) (define-key org-mode-map (kbd "C-c c #") "#+CAPTION: ") (define-key org-mode-map (kbd "C-c l #") "#+LATEX_HEADER: ") (define-key org-mode-map (kbd "C-c f c 4 2") 'setfillcolumn42) (define-key org-mode-map (kbd "C-c f c 7 2") 'setfillcolumn72) (setq org-odt-category-map-alist '(("__Figure__" "*Figure*" "value" "Figure" org-odt--enumerable-image-p))) ; let ess not ask for starting directory (setq ess-ask-for-ess-directory nil) ;(setq org-latex-pdf-process '("latexmk -pdflatex='xelatex ;-output-directory=../output/tex/ -interaction nonstopmode' -pdf ;-bibtex -f %f")) (setq org-latex-logfiles-extensions (quote("bcf" "blg" "fdb_latexmk" "fls" "figlist" "idx" "log" "nav" "out" "ptc" "run.xml" "snm" "toc" "vrb" "xdv"))) ; deactivate link resolving (setq org-activate-links nil) #+END_SRC # # # # ---------------------------------------------------------------------- ** End preamble :ignore: # ---------------------------------------------------------------------- * The poster :PROPERTIES: :BEGIN: :BEAMER_env: fullframe :END: ** Code :ignore: # Babel code can go here to populate the poster with dynamic output ** Left column :BMCOL: :PROPERTIES: :BEAMER_col: 0.45 :BEAMER_opt: [t] :END: *** Background :B_block: :PROPERTIES: :BEAMER_env: block :END: - Here we show how org-mode (version src_elisp{org-version} {{{results(9.1.7)}}}) and emacs (version src_elisp{emacs-version} {{{results(25.2.2)}}}) can be used to make decent looking scientific posters - With org-mode we can populate the poster with code, graphs and numbers from inline code in languages such as R, python, Matlab and even shell scripting - For example, this poster was created on {{{time(%Y-%m-%d %H:%M)}}} on src_bash{lsb_release -sd} {{{results(Ubuntu 17.10)}}}. - Inline code could look like this (which will produce a graph; Fig. [[figcode1]]): **** Block :PROPERTIES: :BEAMER_col: 0.68 :BEAMER_opt: [T] :END: #+NAME: code1 #+BEGIN_SRC R :file 3.png :session :exports both :results graphics set.seed(20180402) x1 <- rnorm(100, 0, 1) x2 <- rnorm(100, 0.5, 1) hist(x1, col="red") hist(x2, col="blue", add=TRUE) #+END_SRC #+NAME: figcode1 #+CAPTION: This is the output. #+RESULTS: code1 [[file:3.png]] *** Inline code and tables :B_block: :PROPERTIES: :BEAMER_env: block :END: - Tables are powerful in org-mode and even include spreadsheet capabilities - Some code to process the first vector from above to make a table out of its summary could look like this, which would result in a little table (Table [[tabcode2]]) : **** Block :PROPERTIES: :BEAMER_col: 0.78 :BEAMER_opt: [T] :END: #+NAME: code2 #+BEGIN_SRC R :session :exports both :results value :colnames yes :cache yes library(broom) library(dplyr) t1 <- tidy(round(summary(x1), 2)) t2 <- tidy(round(summary(x2), 2)) # This will export as a table rbind(t1, t2) %>% mutate(name=c("x1", "x2")) #+END_SRC \vspace{2cm} \small #+CAPTION: A table summarizing the two distributions. #+NAME: tabcode2 #+RESULTS[9d0ec7348265a5cb6de39440ff06a8dbb8e5ecf1]: code2 |---------+-------+--------+------+------+---------+------| | minimum | q1 | median | mean | q3 | maximum | name | |---------+-------+--------+------+------+---------+------| | -2.29 | -0.49 | 0.11 | 0.14 | 0.8 | 2.47 | x1 | | -2.17 | -0.45 | 0.07 | 0.13 | 0.85 | 2.23 | x2 | |---------+-------+--------+------+------+---------+------| ** Right column :BMCOL: :PROPERTIES: :BEAMER_col: 0.45 :BEAMER_opt: [t] :END: *** Graphics :B_block: :PROPERTIES: :BEAMER_env: block :END: - We can use shell scripting to grab an image with curl from the internet (Fig. [[figcode3]]): **** Block :PROPERTIES: :BEAMER_col: 0.78 :BEAMER_opt: [T] :END: \footnotesize #+NAME: code3 #+BEGIN_SRC bash :exports both :file emacs.png # Download emacs icon from gnu.org curl -0 https://www.gnu.org/software/emacs/images/emacs.png #+END_SRC \normalsize \vspace{2cm} #+ATTR_LATEX: :width 0.2\textwidth :options page=9 #+NAME: figcode3 #+CAPTION: This is the downloaded image. #+RESULTS: code3 [[file:emacs.png]] *** Math :B_block: :PROPERTIES: :BEAMER_env: block :END: - Let's describe how to compute the distance between the two simulated distributions $x1$ and $x2$ from before: **** Block :PROPERTIES: :BEAMER_col: 0.78 :BEAMER_opt: [T] :END: \small The Kullback-Leibler (KL) divergence measures the difference between two probability distributions (i.e., the loss of information when one distribution is used to approximate another). The KL divergence is thus defined as # \begin{align} \label{eq:KL} \DKLPQ{P}{Q}{\|} = \sumin \Xoi{P} \log \frakPQ{P}{Q} \end{align} # with $P$ and $Q$ being two probability distribution functions and $n$ the number of sample points. Since $\DKLPQ{P}{Q}{\|}$ is not equal to $\DKLPQ{Q}{P}{\|}$, a symmetric variation of the KL divergence can be derived as follows: # \small \begin{align} \label{eq:KL2} \DKLPQ{P}{Q}{,} = \sumin \Big(\Xoi{P} \log \frakPQ{P}{Q} + \Xoi{Q} \log \frakPQ{Q}{P} \Big). \end{align} *** Columns :B_block: :PROPERTIES: :BEAMER_env: block :END: **** Left :PROPERTIES: :BEAMER_col: 0.48 :BEAMER_opt: [T] :END: #+NAME: codeleft #+BEGIN_SRC R :file 4l.png :session :exports results :results graphics d1 <- density(x1) plot(d1, col="red", lwd=3) #+END_SRC \captionsetup{justification=justified,width=.85\linewidth} #+NAME: figcodeleft #+CAPTION: This is the left figure of a two-column block, showing #+CAPTION: the density of $x1$. #+RESULTS: codeleft [[file:4l.png]] **** Right :PROPERTIES: :BEAMER_col: 0.48 :BEAMER_opt: [T] :END: #+NAME: coderight #+BEGIN_SRC R :file 4r.png :session :exports results :results graphics d2 <- density(x2) plot(d2, col="blue", lwd=3) #+END_SRC \captionsetup{justification=justified,width=.85\linewidth} #+NAME: figcoderight #+CAPTION: This is the right figure. It shows the density of $x2$. #+RESULTS: coderight [[file:4r.png]] *** Conclusions :B_block: :PROPERTIES: :BEAMER_env: block :END: - This example is meant to show how versatile org-mode is - Scientific posters can be produced with a simple text editor