This repo still under construction ❗
click to see the image in full size
- you can use any Emacs package manager you want, but i prefer
using straight.el.
Straight.el config
;;------------------------- ;; MANDATORY PACKAGES ;;------------------------- ;; installing and configure STRAIGHT (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 5)) (unless (file-exists-p bootstrap-file) (with-current-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) ;; use use-package along with straight (straight-use-package 'use-package) ;; make `use-package` to automatically install all of your packages ;; without the need for adding `:straight t`. (setq straight-use-package-by-default t)
- org
org mode installation & configuration
;; Installing ORG (use-package org)
- org-contrib
here we can see the usefulness of
straight.el
packages managerorg contrib installation & configuration
;; Installing and configure ORG-CONTRIB (use-package org-contrib :config (require 'ox-extra) (ox-extras-activate '(latex-header-blocks ignore-headlines)))
- org-ref: John Kitchin (i might replace it with org-cite or
org-ref-cite “org-refv3” in the future)
org-ref installation & configuration
;; Installing ORG-REF (use-package org-ref :after org :config (setq org-ref-default-bibliography '("<path/to/your/bibliography>") org-ref-bibliography-notes "<path/to/your/bibliography>" org-ref-pdf-directory "<path/to/your/papers/folder>" org-ref-get-pdf-filename-function 'org-ref-get-pdf-filename-helm-bibtex bibtex-completion-pdf-field "file" bibtex-completion-pdf-symbol "" bibtex-completion-display-formats '((t . "${title:46} ${author:20} ${year:4} ${=type=:4}${=has-pdf=:1}${=has-note=:1}")))) (defun org-ref-open-in-scihub () "Open the bibtex entry at point in a browser using the url field or doi field. Not for real use, just here for demonstration purposes." (interactive) (let ((doi (org-ref-get-doi-at-point))) (when doi (if (string-match "^http" doi) (browse-url doi) (browse-url (format "http://sci-hub.se/%s" doi))) (message "No url or doi found")))) #+end_src
- ox-latex
- Linux
- Arch-based (Artix, Manjaro, Parabola):
pacman -S texlive-most texlive-lang
- Debian-based (Ubuntu/Linux Mint):
apt-get install texlive-full
- Some distros (like Void) use tlmgr to install TeX packages instead of the main package manager.
- Arch-based (Artix, Manjaro, Parabola):
- Windows: Here. (Choose the net install to be able to install all packages.)
- MacOS: Here
- follow the instruction on the latex-mimosis repo on how you can add
this library and use it on your project
- long story short, copy the files
mimosis.cls
andbibliography-mimosis.tex
into your root project directory
- long story short, copy the files
- call the setupfile using the
#+SETUPFILE:
keyword, in our case here:#+SETUPFILE: ./lib/thesis.setup
- this file contain all the configuration i used in my org-master, you can modify it by yourself and add any extra configuration you see fit.
- add org, org-ref and latex configuration to your init.el, (this is the emacs’s configuration file), you can use my own configuration
./lib/code.inc
: contain function for cleaning, exporting and building, i use them throughout my work using the keyword#+CALL
- an example for that is when i used the
init()
function to clean my root directory. - first include the
./lib/code.inc
file, then call whatever function you want.#+INCLUDE: ./lib/code.inc #+CALL: init()
- an example for that is when i used the
(eval-after-load "org"
(use-package ob-async
:ensure t
:init (require 'ob-async)))
(setq org-confirm-babel-evaluate nil
org-src-fontify-natively t
org-confirm-babel-evaluate nil
org-src-tab-acts-natively t)
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)
(shell . t)
(emacs-lisp . t)
(R . t)
))
(use-package org-ref
:config
(setq reftex-default-bibliography '("/path/to/your/bibliography"))
;; see org-ref for use of these variables
(setq org-ref-bibliography-notes "/path/to/your/bib/notes"
org-ref-default-bibliography '("/path/to/your/bibliography")
org-ref-pdf-directory "/path/to/your/papers"
bibtex-dialect 'biblatex
;; Optimize for 80 character frame display
bibtex-completion-display-formats
'((t . "${title:46} ${author:20} ${year:4} ${=type=:3}${=has-pdf=:1}${=has-note=:1}"))
bibtex-completion-bibliography "/path/to/your/bibliography"
bibtex-completion-library-path "/path/to/your/bib/notes"
bibtex-completion-pdf-symbol ""
bibtex-completion-notes-symbol ""
))
(with-eval-after-load 'ox-latex
(add-to-list 'org-latex-classes
'("elsarticle"
"\\documentclass{elsarticle}
[NO-DEFAULT-PACKAGES]
[PACKAGES]
[EXTRA]"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
(add-to-list 'org-latex-classes
'("mimosis"
"\\documentclass{mimosis}
[NO-DEFAULT-PACKAGES]
[PACKAGES]
[EXTRA]
\\newcommand{\\mboxparagraph}[1]{\\paragraph{#1}\\mbox{}\\\\}
\\newcommand{\\mboxsubparagraph}[1]{\\subparagraph{#1}\\mbox{}\\\\}"
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\mboxparagraph{%s}" . "\\mboxparagraph*{%s}")
("\\mboxsubparagraph{%s}" . "\\mboxsubparagraph*{%s}")))
(add-to-list 'org-latex-classes
'( "koma-article"
"\\documentclass{scrartcl}"
( "\\section{%s}" . "\\section*{%s}" )
( "\\subsection{%s}" . "\\subsection*{%s}" )
( "\\subsubsection{%s}" . "\\subsubsection*{%s}" )
( "\\paragraph{%s}" . "\\paragraph*{%s}" )
( "\\subparagraph{%s}" . "\\subparagraph*{%s}" )))
)
;; Coloured LaTeX using Minted
(setq org-latex-listings 'minted
org-latex-packages-alist '(("" "minted"))
org-latex-pdf-process
'("latexmk -pdflatex='xelatex -shell-escape -interaction nonstopmode' -pdf -bibtex -output-directory=%o -f %f"))
;; syntex-highlighting
(use-package htmlize)
;;Don’t include a footer...etc in exported HTML document.
(setq org-html-postamble nil)
(setq org-src-window-setup 'current-window)
(add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
(add-hook 'org-mode-hook 'org-display-inline-images)
(custom-set-variables
'(org-export-backends '(ascii beamed html calendar latex DOT)))
(defun enable-writing-minor-modes ()
"Enable flyspell and visual line mode for calling from mode hooks"
(visual-line-mode 1)
(flyspell-mode 1))
(use-package org
:hook (org-mode . enable-writing-minor-modes))
- use
make build
to build the .pdf file,make clean
to clean the temp files,make watch
to sync your modification with the preview using your PDF viewer
you can specify your PDF viewer application in the latexmkrc file
Main file configuration
#+TITLE: my org thesis
#+SUBTITLE: it is great to use Emacs
#+LATEX_CLASS: mimosis
#+latex_header: \KOMAoptions{headings=small,fontsize=12,DIV=12}
#+SETUPFILE: ./lib/thesis.setup
#+INCLUDE: ./lib/gls_ac.setup
#+INCLUDE: ./lib/code.inc
#+CALL: init()
#+EXCLUDE_TAGS: journal noexport ignore
#+EXPORT_FILE_NAME: org-master.pdf
# ---------------------------------------------------------------------
#+INCLUDE: "./title.org"
#+latex_header: \pagenumbering{arabic}
#+begin_export latex
\listoffigures
\listoftables
\printglossaries
\appendix
#+end_export
#+begin_export latex
\bibliographystyle{unsrt}
\bibliography{./lib/refs.bib}{}
#+end_export
* Build :noexport:
# Bind derivatives change variable values *locally* on export.
These two are here because I'm defining the title and toc manually using latex, so I don't want org-latex to take care of that.
#+BIND: org-latex-title-command ""
#+BIND: org-latex-toc-command ""
This is so that src code blocks get src highlighting from the minted package.
#+BIND: org-latex-listings minted
This beautifies table borders. It will only work if the booktabs package is loaded, which I do in the setup file.
#+BIND: org-latex-tables-booktabs t
And this configuration increases the default width of images, so that they are larger and more readable on print.
#+BIND: org-latex-image-default-width ".97\\linewidth"