My LaTeX environment
Table of Contents
In this post I will describe briefly my latex setup using emacs. I've been writing all kinds of text with \(\LaTeX\) for the past 4 years or so, mainly: reports, assignments, articles, presentations, posters and thesis. My setup when I started was basically MiKTeX with the Texmaker IDE. It was a convenient setup, It worked as expected.
Then, last year I decided to switch to emacs, the main reason was because I was doing a lot of Python and wanted a simple environment to do all work instead of using a bunch of different applications. I have to say that emacs is very addictive, as you start build your own configuration you soon find yourself deeply attached to it. The best thing about it is that it grows with you and becomes better and better.
Emacs is an extensible text editor which means that users can extend its funcionalities by writing functions in elips that can improve their workflow. Users have been writing packages that perform a wide range of tasks, from editing code (pretty much all languages are supported) to interacting with git (magit) and pdf (pdf-tools). More information about emacs can be found here.
The main package that I use is
use-package for package management in emacs.
This package is fairly recent, It was created is 2012 by John Wiegley, the current emacs maintainer.
It's a very convenient way to organize all configuration for a specific package and also specify when a package will load.
For my current setup I'm using the following packages:
What is Auctex
Auctex is a package that helps on writing \(\LaTeX\).
How I use it?
I use it to insert most of latex macros and to compile the pdf.
(use-package tex-site :ensure auctex :mode ("\\.tex\\'" . latex-mode) :config (setq TeX-auto-save t) (setq TeX-parse-self t) (setq-default TeX-master nil) (add-hook 'LaTeX-mode-hook (lambda () (rainbow-delimiters-mode) (company-mode) (smartparens-mode) (turn-on-reftex) (setq reftex-plug-into-AUCTeX t) (reftex-isearch-minor-mode) (setq TeX-PDF-mode t) (setq TeX-source-correlate-method 'synctex) (setq TeX-source-correlate-start-server t))) ;; Update PDF buffers after successful LaTeX runs (add-hook 'TeX-after-TeX-LaTeX-command-finished-hook #'TeX-revert-document-buffer) ;; to use pdfview with auctex (add-hook 'LaTeX-mode-hook 'pdf-tools-install) ;; to use pdfview with auctex (setq TeX-view-program-selection '((output-pdf "pdf-tools")) TeX-source-correlate-start-server t) (setq TeX-view-program-list '(("pdf-tools" "TeX-pdf-tools-sync-view"))))
What is Reftex
Reftex is a package that helps inserting labels, references and citations.
How I use it?
I mainly use it to add references to images and equations.
(use-package reftex :ensure t :defer t :config (setq reftex-cite-prompt-optional-args t)); Prompt for empty optional arguments in cite
What is ivy-bibtex
Is a package that helps you insert citations. It searches on your specified .bib file and the pdf folder.
How I use it?
This package is great, I use it to insert references into .org and .tex files. Also use it to open the pdf of the references.
I use zotero to organize my references, it can retrieve pdf metadata, rename files, categorize files, and so on. It creates a bibtex entry automatically (autoupdate the .bib file) when I add a parent item to a pdf, then it renames the pdf according with the bibtex key and move the file to a specific folder. From this folder I can open the pdf within emacs.
(use-package ivy-bibtex :ensure t :bind ("C-c b b" . ivy-bibtex) :config (setq bibtex-completion-bibliography '("C:/Users/Nasser/OneDrive/Bibliography/references-zot.bib")) (setq bibtex-completion-library-path '("C:/Users/Nasser/OneDrive/Bibliography/references-pdf" "C:/Users/Nasser/OneDrive/Bibliography/references-etc")) ;; using bibtex path reference to pdf file (setq bibtex-completion-pdf-field "File") ;;open pdf with external viwer foxit (setq bibtex-completion-pdf-open-function (lambda (fpath) (call-process "C:\\Program Files (x86)\\Foxit Software\\Foxit Reader\\FoxitReader.exe" nil 0 nil fpath))) (setq ivy-bibtex-default-action 'bibtex-completion-insert-citation))
What is pdf-tools
Pdf-tools is a package for viewing and interacting with pdf within emacs.
How I use it?
I just use it to visualize the pdf inside emacs. One killer feature is that I can jump between source-pdf.
(use-package pdf-tools :ensure t :mode ("\\.pdf\\'" . pdf-tools-install) :bind ("C-c C-g" . pdf-sync-forward-search) :defer t :config (setq mouse-wheel-follow-mouse t) (setq pdf-view-resize-factor 1.10))