2022-03-28 15:03:21 +02:00
#+title : :lang latex
#+subtitle : Writing papers in Emacs has never been so fun
#+created : January 16, 2017
#+since : 1.3
2021-10-16 01:28:32 +02:00
* Description :unfold:
2018-01-01 20:48:23 +01:00
Provide a helping hand when working with LaTeX documents.
2021-10-16 01:28:32 +02:00
- Sane defaults
- Fontification of many popular commands
2022-09-26 02:19:42 +08:00
- Pretty indentation of wrapped lines using the [[doom-package:adaptive-wrap ]] package
- Spell checking with [[doom-package:flycheck ]]
- Change PDF viewer to Okular or [[doom-package:latex-preview-pane ]]
2021-10-16 01:28:32 +02:00
- Bibtex editor
2022-09-26 02:19:42 +08:00
- Autocompletion using [[doom-package:company-mode ]]
2021-10-16 01:28:32 +02:00
- Compile your =.tex= code only once using LatexMk
** Maintainers
- [[doom-user: ][@tecosaur ]]
- [[doom-user: ][@ymarco ]]
[[doom-contrib-maintainer: ][Become a maintainer? ]]
** Module flags
- +cdlatex ::
2022-09-26 02:19:42 +08:00
Enable [[doom-package:cdlatex ]] for fast math insertion.
2021-10-16 01:28:32 +02:00
- +fold ::
2022-09-26 02:19:42 +08:00
Use TeX-fold (from [[doom-package:auctex ]]) to fold LaTeX macros to unicode, and make folding
2021-10-16 01:28:32 +02:00
hook-based and less manual.
- +latexmk ::
Use LatexMk instead of LaTeX to compile documents.
- +lsp ::
2022-09-26 02:19:42 +08:00
Enable LSP support in latex buffers. Requires [[doom-module::tools lsp ]] and a langserver
2021-10-16 01:28:32 +02:00
(supports digestif and TexLab).
** Packages
2022-09-26 02:19:42 +08:00
- [[doom-package:adaptive-wrap ]]
- [[doom-package:auctex ]]
- [[doom-package:auctex-latexmk ]] if [[doom-module:+latexmk ]]
- [[doom-package:cdlatex ]] if [[doom-module:+cdlatex ]]
- [[doom-package:evil-tex ]] if [[doom-module::editor evil +everywhere ]]
- [[doom-package:latex-preview-pane ]]
- if [[doom-module::completion company ]]
- [[doom-package:company-auctex ]]
- [[doom-package:company-math ]]
- [[doom-package:company-reftex ]]
2021-10-16 01:28:32 +02:00
** TODO Hacks
#+begin_quote
🔨 This module's hacks haven't been documented yet. [[doom-contrib-module: ][Document them? ]]
#+end_quote
** TODO Changelog
# This section will be machine generated. Don't edit it by hand.
/This module does not have a changelog yet./
* Installation
[[id:01cffea4-3329-45e2-a892-95a384ab2338 ][Enable this module in your ~doom!~ block. ]]
This module requires ghostscript and a latex compiler. These are provided by the
=texlive= bundle, available through many OS package managers.
#+begin_quote
🚧 Ghostscript <= 9.27 is [[/auctex/manual/preview-latex/No-images-are-displayed-with-gs-9_002e27-and-earlier.html ][reportedly buggy ]] and doesn't work with auctex's math
previews. (You can check you ghostscript version with ~$ gs --version~ .)
Most package managers already have newer versions, but if not you might have
to build gs from source.
#+end_quote
2020-04-07 15:00:38 -04:00
** Ubuntu
2021-10-16 01:28:32 +02:00
#+begin_src sh
2020-04-07 15:00:38 -04:00
apt-get install texlive
2021-10-16 01:28:32 +02:00
#+end_src
2020-04-07 15:00:38 -04:00
** Arch Linux
2021-10-16 01:28:32 +02:00
#+begin_src sh
2020-10-13 01:11:42 -07:00
pacman -S texlive-core
2021-10-16 01:28:32 +02:00
#+end_src
2020-04-07 15:00:38 -04:00
** TODO macOS
2021-10-16 01:28:32 +02:00
#+begin_src sh
2021-04-21 21:09:56 +03:00
brew install --cask basictex
2020-04-07 15:00:38 -04:00
# If the above doesn't work, then
2021-04-21 21:09:56 +03:00
brew install --cask mactex # WARNING: large 4gb download!
2021-10-16 01:28:32 +02:00
#+end_src
2020-04-07 15:00:38 -04:00
#+begin_quote
2021-10-16 01:28:32 +02:00
🔨 This has not been verified.
2020-04-07 15:00:38 -04:00
#+end_quote
** NixOS
2021-10-16 01:28:32 +02:00
#+begin_src nix
2020-04-07 15:00:38 -04:00
environment.systemPackages = [ pkgs.texlive.combined.scheme-medium ];
2021-10-16 01:28:32 +02:00
#+end_src
2019-11-21 14:45:18 -05:00
2021-10-16 01:28:32 +02:00
* TODO Usage
#+begin_quote
🔨 This module has no usage documentation yet. [[doom-contrib-module: ][Write some? ]]
#+end_quote
2018-04-11 13:02:58 +02:00
2021-10-16 01:28:32 +02:00
* Configuration
2019-01-05 17:45:42 -05:00
** Specifying the location of a bibtex file & corresponding PDFs
2021-10-16 01:28:32 +02:00
Reftex has a variable that allow you to specify where it should find your
bibliography file(s):
#+begin_src emacs-lisp
;; in $DOOMDIR/config.el
2019-01-05 17:45:42 -05:00
(setq reftex-default-bibliography "/your/bib/file.bib")
2021-10-16 01:28:32 +02:00
#+end_src
2018-01-01 20:48:23 +01:00
2019-01-05 17:45:42 -05:00
** Changing the PDFs viewer
This module provides integration for four supported pdf viewers. They are
2018-01-01 20:48:23 +01:00
2019-01-05 17:45:42 -05:00
+ [[https://skim-app.sourceforge.io/ ][Skim.app ]] (MacOS only)
2019-09-28 18:28:48 +02:00
+ Evince
+ Sumatra PDF
2019-01-05 17:45:42 -05:00
+ Zathura
2019-09-28 18:28:48 +02:00
+ Okular
2022-09-26 02:19:42 +08:00
+ pdf-tools (requires [[doom-module::tools pdf ]] module)
2018-04-11 13:02:58 +02:00
2019-01-05 17:45:42 -05:00
They are searched for in this order. See ~+latex-viewers~ to change the order,
or remove tools from the search altogether. If you want to exclusively use one
tool, for instance:
2021-10-16 01:28:32 +02:00
#+begin_src emacs-lisp
;; in $DOOMDIR/config.el
2019-01-05 17:45:42 -05:00
(setq +latex-viewers '(zathura))
2021-10-16 01:28:32 +02:00
#+end_src
2018-04-11 13:02:58 +02:00
2019-01-05 17:45:42 -05:00
If none of these tools are found, ~latex-preview-pane~ (uses ~DocView~ in Emacs)
is used as a fallback. You can use this exclusively by setting ~+latex-viewers~
to ~nil~ .
2020-02-07 12:36:07 +02:00
** Using cdlatex's snippets despite having yasnippet
2022-09-26 02:19:42 +08:00
[[doom-package:cdlatex ]] has a snippet insertion capability which is disabled in favor of
[[doom-package:yasnippet ]] when using [[doom-module::editor snippets ]]. If you still wanna use it, simply rebind
2021-10-16 01:28:32 +02:00
the [[kbd: ][TAB ]] key for cdlatex, which takes care of snippet-related stuff:
#+begin_src emacs-lisp
;; in $DOOMDIR/config.el
2020-02-07 12:36:07 +02:00
(map! :map cdlatex-mode-map
2021-10-16 01:28:32 +02:00
:i "TAB" #'cdlatex-tab)
#+end_src
2020-02-07 12:36:07 +02:00
This would favor yasnippet's expansion and cursor movement over cdlatex's
expansion and movement, but that shouldn't matter if you're not using yasnippet
in latex buffers.
2021-10-16 01:28:32 +02:00
* Troubleshooting
/There are no known problems with this module./ [[doom-report: ][Report one? ]]
* Frequently asked questions
/This module has no FAQs yet./ [[doom-suggest-faq: ][Ask one? ]]
* TODO Appendix
#+begin_quote
🔨 This module has no appendix yet. [[doom-contrib-module: ][Write one? ]]
#+end_quote