2015-12-02 14:23:39 +00:00
|
|
|
|
#+TITLE: LaTeX layer
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
2019-05-07 08:21:07 +00:00
|
|
|
|
#+TAGS: dsl|layer|markup|programming
|
2019-05-05 17:26:40 +00:00
|
|
|
|
|
2015-06-10 16:44:30 +00:00
|
|
|
|
[[file:img/latex.png]]
|
|
|
|
|
|
2019-05-07 20:05:06 +00:00
|
|
|
|
* Table of Contents :TOC_5_gh:noexport:
|
2017-05-22 14:16:12 +00:00
|
|
|
|
- [[#description][Description]]
|
2017-08-06 02:14:10 +00:00
|
|
|
|
- [[#features][Features:]]
|
2019-04-21 20:04:25 +00:00
|
|
|
|
- [[#bibtex][BibTeX]]
|
2017-05-22 14:16:12 +00:00
|
|
|
|
- [[#install][Install]]
|
2020-10-27 21:48:22 +00:00
|
|
|
|
- [[#configuration][Configuration]]
|
|
|
|
|
- [[#choosing-a-backend][Choosing a backend]]
|
|
|
|
|
- [[#company-auctex][Company-auctex]]
|
|
|
|
|
- [[#lsp][LSP]]
|
2017-05-22 14:16:12 +00:00
|
|
|
|
- [[#previewing][Previewing]]
|
|
|
|
|
- [[#build-command][Build command]]
|
|
|
|
|
- [[#auto-fill][Auto-fill]]
|
|
|
|
|
- [[#folding][Folding]]
|
2015-12-11 22:14:56 +00:00
|
|
|
|
- [[#magic-latex-buffer][Magic latex buffer]]
|
2018-10-23 14:18:21 +00:00
|
|
|
|
- [[#key-bindings][Key bindings]]
|
2017-05-22 14:16:12 +00:00
|
|
|
|
- [[#folding-1][Folding]]
|
|
|
|
|
- [[#reftex][RefTeX]]
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
|
|
|
|
* Description
|
|
|
|
|
This layer adds support for LaTeX files with [[https://savannah.gnu.org/projects/auctex/][AucTeX]].
|
|
|
|
|
|
2017-08-06 02:14:10 +00:00
|
|
|
|
** Features:
|
2015-08-11 11:46:59 +00:00
|
|
|
|
- Auto-build with [[https://github.com/tom-tan/auctex-latexmk/][auctex-latexmk]]
|
2020-10-27 21:48:22 +00:00
|
|
|
|
- Syntax highlighting
|
|
|
|
|
- Auto-completion
|
2015-06-10 21:16:01 +00:00
|
|
|
|
- Tags navigation on ~%~ with [[https://github.com/redguardtoo/evil-matchit][evil-matchit]]
|
|
|
|
|
- Labels, references, citations and index entries management with [[http://www.gnu.org/software/emacs/manual/html_node/reftex/index.html][RefTeX]]
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
2019-04-21 19:00:24 +00:00
|
|
|
|
* BibTeX
|
2016-04-17 02:32:11 +00:00
|
|
|
|
For more extensive support of BibTeX files than RefTeX provides, have a look at
|
2017-08-18 19:07:43 +00:00
|
|
|
|
the [[https://github.com/syl20bnr/spacemacs/blob/develop/layers/%2Blang/bibtex/README.org][BibTeX layer]].
|
2016-04-17 02:32:11 +00:00
|
|
|
|
|
2015-06-10 16:44:30 +00:00
|
|
|
|
* Install
|
2016-01-06 05:21:55 +00:00
|
|
|
|
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
|
|
|
|
|
add =latex= to the existing =dotspacemacs-configuration-layers= list in this
|
|
|
|
|
file.
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
2020-10-27 21:48:22 +00:00
|
|
|
|
* Configuration
|
|
|
|
|
Most layer configurations can be done by setting layer variables in your dotfile.
|
|
|
|
|
Some however require adding lines to your user-config.
|
|
|
|
|
|
|
|
|
|
** Choosing a backend
|
|
|
|
|
This layer provides two alternative backends to choose from.
|
|
|
|
|
|
|
|
|
|
*** Company-auctex
|
|
|
|
|
This is the default choice if nothing is set and no lsp layer
|
|
|
|
|
is loaded in your dotfile. This mode only provides very
|
|
|
|
|
limited IDE capabilities. Used best for smaller documents.
|
|
|
|
|
To set explicitly set the following in your
|
|
|
|
|
dotfile:
|
|
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
(latex :variables latex-backend 'company-auctex)
|
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
|
|
*** LSP
|
|
|
|
|
For proper IDE support this backend should be used. It is
|
|
|
|
|
based on an external server which will be started automatically
|
|
|
|
|
by emacs, once a latex file is opened. The key bindings are
|
|
|
|
|
the same for all lsp modes so if you are already familiar with
|
|
|
|
|
one you should be able to work the same in all modes.
|
|
|
|
|
|
|
|
|
|
To set explicitly do the following in your dotfile:
|
|
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
(latex :variables
|
|
|
|
|
latex-backend 'lsp)
|
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
|
|
For this to work you will also need to obtain
|
|
|
|
|
the latest version of the lsp server from [[https://github.com/latex-lsp/texlab][here]]
|
|
|
|
|
and put it into your =PATH=.
|
|
|
|
|
|
|
|
|
|
NOTE: Key bindings for LSP are defined in the
|
|
|
|
|
LSP layer. Also it is advisable to have a look
|
|
|
|
|
at the autocomplete layer for an optimal
|
|
|
|
|
intellisense config for LSP.
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
|
|
|
|
** Previewing
|
|
|
|
|
To perform full-document previews (that is, aside from the inline previewing
|
2017-08-09 09:25:35 +00:00
|
|
|
|
under ~SPC m p~), add the following to your =.spacemacs= under
|
|
|
|
|
=dotspacemacs/user-config=:
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
(add-hook 'doc-view-mode-hook 'auto-revert-mode)
|
|
|
|
|
#+END_SRC
|
|
|
|
|
|
2017-08-09 09:25:35 +00:00
|
|
|
|
Then when you open up a compiled PDF, the preview will update automatically when
|
|
|
|
|
you recompile.
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
|
|
|
|
** Build command
|
2015-08-11 11:46:59 +00:00
|
|
|
|
A build command can be specified via the layer variable =latex-build-command=.
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
2017-08-09 09:25:35 +00:00
|
|
|
|
If =LatexMk= is specified, the appropriate =LatexMk= configuration will be
|
|
|
|
|
applied. (the default on systems with =latexmk= in the path) This variable can
|
|
|
|
|
be set to any of the entities in =TeX-command-list=, including any custom
|
|
|
|
|
entries you may have added there. To use the regular =AucTeX= command set
|
|
|
|
|
=latex-build-command= to =LaTeX= as shown below.
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
dotspacemacs-configuration-layers '(
|
2015-08-11 11:46:59 +00:00
|
|
|
|
(latex :variables latex-build-command "LaTeX"))
|
2015-06-10 16:44:30 +00:00
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
|
|
** Auto-fill
|
2016-11-27 16:58:39 +00:00
|
|
|
|
To disable auto-fill (which is on by default) set the variable
|
|
|
|
|
=latex-enable-auto-fill= to =nil=.
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
|
|
|
|
The variable =latex-nofill-env= provide the list of environment names where
|
2015-10-24 14:20:03 +00:00
|
|
|
|
=auto-fill-mode= will be inhibited.
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
dotspacemacs-configuration-layers '(
|
2016-11-27 16:58:39 +00:00
|
|
|
|
(latex :variables latex-enable-auto-fill nil))
|
2015-06-10 16:44:30 +00:00
|
|
|
|
#+END_SRC
|
|
|
|
|
|
2016-01-04 04:51:19 +00:00
|
|
|
|
** Folding
|
|
|
|
|
Enable folding of text by setting =latex-enable-folding= to =t=. Default value
|
|
|
|
|
is nil.
|
|
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
dotspacemacs-configuration-layers '(
|
|
|
|
|
(latex :variables latex-enable-folding t))
|
|
|
|
|
#+END_SRC
|
|
|
|
|
|
2015-12-11 22:14:56 +00:00
|
|
|
|
** Magic latex buffer
|
2019-05-26 20:58:52 +00:00
|
|
|
|
To enable "magic" symbols in latex buffers, set the variable
|
2015-12-11 22:14:56 +00:00
|
|
|
|
=latex-enable-magic= to =t=.
|
|
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
dotspacemacs-configuration-layers '(
|
|
|
|
|
(latex :variables latex-enable-magic t))
|
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
|
|
The precise effect of this feature can be modified by adjusting the following
|
|
|
|
|
variables:
|
|
|
|
|
- =magic-latex-enable-block-highlight=: show font properties like =\large=
|
|
|
|
|
(default =t=).
|
|
|
|
|
- =magic-latex-enable-block-align=: reflect block alignment such as =\center=
|
|
|
|
|
(default =nil=).
|
|
|
|
|
- =magic-latex-enable-pretty-symbols=: substitute symbols in place of code, e.g.
|
|
|
|
|
greek letters (default =t=).
|
|
|
|
|
- =magic-latex-enable-suscript=: show subscripts and superscripts (default =t=).
|
|
|
|
|
- =magic-latex-enable-inline-image=: show images inline (default =nil=).
|
|
|
|
|
|
|
|
|
|
By default, the underlying latex code is echoed in the echo area.
|
|
|
|
|
|
2018-10-23 14:18:21 +00:00
|
|
|
|
* Key bindings
|
2016-04-17 02:32:11 +00:00
|
|
|
|
|
2020-10-27 21:48:22 +00:00
|
|
|
|
| Key binding | Description |
|
|
|
|
|
|-----------------------------------+--------------------------------------------|
|
|
|
|
|
| ~SPC m -~ | recenter output buffer |
|
2020-10-30 20:44:17 +00:00
|
|
|
|
| ~SPC m ,~ | TeX command on master file |
|
2020-10-27 21:48:22 +00:00
|
|
|
|
| ~SPC m .~ | mark LaTeX environment |
|
|
|
|
|
| ~SPC m *~ | mark LaTeX section |
|
|
|
|
|
| ~SPC m %~ | comment or uncomment a paragraph |
|
|
|
|
|
| ~SPC m ;~ | comment or uncomment a region |
|
|
|
|
|
| ~SPC m a~ or with LSP ~SPC m a u~ | run all commands (compile and open viewer) |
|
|
|
|
|
| ~SPC m b~ or with LSP ~SPC m c~ | build the document (compile) |
|
|
|
|
|
| ~SPC m c~ or with LSP ~SPC m i c~ | close LaTeX environment |
|
|
|
|
|
| ~SPC m e~ or with LSP ~SPC m i e~ | insert LaTeX environment |
|
|
|
|
|
| ~SPC m i i~ | insert =\item= |
|
|
|
|
|
| ~SPC m k~ | kill TeX job |
|
|
|
|
|
| ~SPC m l~ | recenter output buffer |
|
|
|
|
|
| ~SPC m m~ | insert LaTeX macro |
|
|
|
|
|
| ~SPC m n~ | goto next error |
|
|
|
|
|
| ~SPC m N~ | goto previous error |
|
|
|
|
|
| ~SPC m s~ | insert LaTeX section |
|
|
|
|
|
| ~SPC m v~ | view output |
|
|
|
|
|
| ~SPC m h d~ | TeX documentation, can be very slow |
|
|
|
|
|
| ~SPC m f e~ | fill LaTeX environment |
|
|
|
|
|
| ~SPC m f p~ | fill LaTeX paragraph |
|
|
|
|
|
| ~SPC m f r~ | fill LaTeX region |
|
|
|
|
|
| ~SPC m f s~ | fill LaTeX section |
|
|
|
|
|
| ~SPC m p r~ | preview region |
|
|
|
|
|
| ~SPC m p b~ | preview buffer |
|
|
|
|
|
| ~SPC m p d~ | preview document |
|
|
|
|
|
| ~SPC m p e~ | preview environment |
|
|
|
|
|
| ~SPC m p s~ | preview section |
|
|
|
|
|
| ~SPC m p p~ | preview at point |
|
|
|
|
|
| ~SPC m p f~ | cache preamble for preview |
|
|
|
|
|
| ~SPC m p c~ | clear previews |
|
|
|
|
|
| ~SPC m v~ | view |
|
|
|
|
|
| ~SPC m x b~ | make font bold |
|
|
|
|
|
| ~SPC m x B~ | make font medium weight |
|
|
|
|
|
| ~SPC m x c~ | make font monospaced (for code) |
|
|
|
|
|
| ~SPC m x e~ | make font emphasised |
|
|
|
|
|
| ~SPC m x i~ | make font italic |
|
|
|
|
|
| ~SPC m x o~ | make font oblique |
|
|
|
|
|
| ~SPC m x r~ | remove font properties |
|
|
|
|
|
| ~SPC m x f a~ | use calligraphic font |
|
|
|
|
|
| ~SPC m x f c~ | use small-caps font |
|
|
|
|
|
| ~SPC m x f f~ | use sans serif font |
|
|
|
|
|
| ~SPC m x f n~ | use normal font |
|
|
|
|
|
| ~SPC m x f r~ | use serif font |
|
|
|
|
|
| ~SPC m x f u~ | use upright font |
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
2016-01-04 04:51:19 +00:00
|
|
|
|
** Folding
|
2016-04-28 17:33:59 +00:00
|
|
|
|
Available only when =latex-enable-folding= is non nil.
|
2016-01-04 04:51:19 +00:00
|
|
|
|
|
2018-12-05 03:03:03 +00:00
|
|
|
|
| Key binding | Description |
|
2016-01-04 04:51:19 +00:00
|
|
|
|
|-------------+----------------------|
|
|
|
|
|
| ~SPC m z =~ | fold TeX math |
|
|
|
|
|
| ~SPC m z b~ | fold TeX buffer |
|
|
|
|
|
| ~SPC m z e~ | fold TeX environment |
|
|
|
|
|
| ~SPC m z m~ | fold TeX macro |
|
|
|
|
|
| ~SPC m z r~ | fold TeX region |
|
|
|
|
|
|
2015-06-10 16:44:30 +00:00
|
|
|
|
** RefTeX
|
|
|
|
|
|
2020-10-27 21:48:22 +00:00
|
|
|
|
| Key binding | Description |
|
|
|
|
|
|-----------------------------------------+---------------------------------------|
|
|
|
|
|
| ~SPC m r c~ or with LSP ~SPC m R c~ | reftex-citation |
|
|
|
|
|
| ~SPC m r g~ or with LSP ~SPC m R g~ | reftex-grep-document |
|
|
|
|
|
| ~SPC m r i~ or with LSP ~SPC m R i~ | reftex-index-selection-or-word |
|
|
|
|
|
| ~SPC m r I~ or with LSP ~SPC m R I~ | reftex-display-index |
|
|
|
|
|
| ~SPC m r TAB~ or with LSP ~SPC m R TAB~ | reftex-index |
|
|
|
|
|
| ~SPC m r l~ or with LSP ~SPC m R l~ | reftex-label |
|
|
|
|
|
| ~SPC m r p~ or with LSP ~SPC m R p~ | reftex-index-phrase-selection-or-word |
|
|
|
|
|
| ~SPC m r P~ or with LSP ~SPC m R P~ | reftex-index-visit-phrases-buffer |
|
|
|
|
|
| ~SPC m r r~ or with LSP ~SPC m R r~ | reftex-reference |
|
|
|
|
|
| ~SPC m r s~ or with LSP ~SPC m R s~ | reftex-search-document |
|
|
|
|
|
| ~SPC m r t~ or with LSP ~SPC m R t~ | reftex-toc |
|
|
|
|
|
| ~SPC m r T~ or with LSP ~SPC m R T~ | reftex-toc-recenter |
|
|
|
|
|
| ~SPC m r v~ or with LSP ~SPC m R v~ | reftex-view-crossref |
|