Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding magic-latex-buffer package to latex layer #4154

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 128 additions & 49 deletions layers/+lang/latex/README.org
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#+TITLE: LaTeX layer
#+TITLE: LaTeX Layer for Spacemacs
#+HTML_HEAD_EXTRA: <link rel="stylesheet" type="text/css" href="../../../css/readtheorg.css" />

[[file:img/latex.png]]
Expand All @@ -12,8 +12,11 @@
- [[Previewing][Previewing]]
- [[Build command][Build command]]
- [[Auto-fill][Auto-fill]]
- [[Magic latex buffer][Magic latex buffer]]
- [[Keybindings][Keybindings]]
- [[AucTeX][AucTeX]]
- [[RefTeX][RefTeX]]
- [[reftex TOC mode][reftex TOC mode]]

* Description
This layer adds support for LaTeX files with [[https://savannah.gnu.org/projects/auctex/][AucTeX]].
Expand All @@ -23,7 +26,6 @@ This layer adds support for LaTeX files with [[https://savannah.gnu.org/projects
- Auto-completion with [[https://github.com/alexeyr/company-auctex][company-auctex]]
- 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]]

* Install
** Layer
To use this contribution add it to your =~/.spacemacs=
Expand All @@ -48,6 +50,10 @@ under =dotspacemacs/user-config=:
Then when you open up a compiled PDF, the preview will update automatically
when you recompile.

Font-locking for semi-WYSIWYG editing made with magic-latex-buffer can be customized.



** Build command
A build command can be specified via the layer variable =latex-build-command=.

Expand All @@ -74,55 +80,128 @@ The variable =latex-nofill-env= provide the list of environment names where
(latex :variables latex-enable-auto-fill t))
#+END_SRC

** Magic latex buffer
Font-locking using magic latex buffer can be customized with the following variables (all toggled by default):

=magic-latex-enable-block-highlight t=
=magic-latex-enable-suscript t=
=magic-latex-enable-pretty-symbols t=
=magic-latex-enable-block-align t=
=magic-latex-enable-inline-image t=

* Keybindings
** AucTeX

| Key Binding | Description |
|---------------+--------------------------------------------------|
| ~SPC m %~ | comment or uncomment paragraph |
| ~SPC m ;~ | comment or uncomment region |
| ~SPC m a m~ | set master in multifile documents |
| ~SPC m c :~ | next command on master |
| ~SPC m c b~ | next commmand on buffer |
| ~SPC m c c~ | build/compile/typeset |
| ~SPC m c r~ | next command on region |
| ~SPC m c s b~ | TeX-command-select-buffer |
| ~SPC m c s r~ | TeX-command-select-region |
| ~SPC m c s~ | Tex-command-select-master |
| ~SPC m c v~ | compile document until error or finished |
| ~SPC m d c~ | remove generated intermediate files |
| ~SPC m d e~ | overview errors/warnings |
| ~SPC m d k~ | kill currently running external application |
| ~SPC m d n~ | jump to next error of last LaTeX run |
| ~SPC m d N~ | jump to previous error of last run |
| ~SPC m d o~ | makes bottom line visible of the output buffer |
| ~SPC m d r~ | remove buffer information and reapply style hook |
| ~SPC m g h~ | go to master file |
| ~SPC m h a~ | help aucTeX |
| ~SPC m h d~ | help TeX |
| ~SPC m h p~ | help preview |
| ~SPC m i c~ | complete macro |
| ~SPC m i E~ | close environment |
| ~SPC m i e~ | prompt for environment to insert |
| ~SPC m i i~ | insert item in itemize-like environment |
| ~SPC m i m~ | insert macro |
| ~SPC m m e~ | mark environment |
| ~SPC m m p~ | pin region |
| ~SPC m m s~ | mark section |
| ~SPC m p b~ | preview buffer |
| ~SPC m p c b~ | remove preview from buffer |
| ~SPC m p c d~ | remove preview from document |
| ~SPC m p c p~ | remove preview at point |
| ~SPC m p c r~ | remove preview from region |
| ~SPC m p c s~ | remove preview from section |
| ~SPC m p d~ | generate preview for document |
| ~SPC m p e~ | generate preview for environment |
| ~SPC m p F~ | generate preview cache preamble off |
| ~SPC m p f~ | generate preview cache preamble |
| ~SPC m p p~ | generate preview at point |
| ~SPC m p r~ | generate preview for region |
| ~SPC m p s~ | generate preview for section |
| ~SPC m s~ | save all buffers known to the current document |
| ~SPC m t $~ | toggle math mode |
| ~SPC m v~ | start a viewer without prompting |
| ~SPC m x b~ | font-bold |
| ~SPC m x B~ | font-medium |
| ~SPC m x c~ | font-typewriter |
| ~SPC m x e~ | font-emphasis |
| ~SPC m x f a~ | font-calligraphic |
| ~SPC m x f c~ | font-small-caps |
| ~SPC m x f f~ | font-sans-serif |
| ~SPC m x f n~ | font-normal |
| ~SPC m x f r~ | font-serif |
| ~SPC m x f u~ | font-upright |
| ~SPC m x i~ | font-italic |
| ~SPC m x o~ | font-slanted |
| ~SPC m x r~ | font-delete |


| Key Binding | Description |
|---------------+-------------------------------------|
| ~SPC m -~ | open output buffer |
| ~SPC m b~ | build |
| ~SPC m c~ | close LaTeX environment |
| ~SPC m C~ | TeX command on master file |
| ~SPC m e~ | insert LaTeX environment |
| ~SPC m i~ | insert =\item= |
| ~SPC m h d~ | TeX documentation, can be very slow |
| ~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 |

** RefTeX

| Key Binding | Description |
|---------------+---------------------------------------|
| ~SPC m r c~ | reftex-citation |
| ~SPC m r g~ | reftex-grep-document |
| ~SPC m r i~ | reftex-index-selection-or-word |
| ~SPC m r I~ | reftex-display-index |
| ~SPC m r TAB~ | reftex-index |
| ~SPC m r l~ | reftex-label |
| ~SPC m r p~ | reftex-index-phrase-selection-or-word |
| ~SPC m r P~ | reftex-index-visit-phrases-buffer |
| ~SPC m r r~ | reftex-reference |
| ~SPC m r s~ | reftex-search-document |
| ~SPC m r t~ | reftex-toc |
| ~SPC m r T~ | reftex-toc-recenter |
| ~SPC m r v~ | reftex-view-crossref |
| | |
| Key Binding | Description |
|---------------+------------------------------------------------------------------------------------|
| ~SPC m r g b~ | create or go to the index phrases file |
| ~SPC m r g l~ | prompt for a label (with completion) and jump to the location of this label |
| ~SPC m r i a~ | index all index phrases in the current region |
| ~SPC m r i c~ | make a citation using BibTeX database files |
| ~SPC m r i i~ | query for an index macro and insert it along with its arguments |
| ~SPC m r i I~ | put current selection or the word near point into the default index macro |
| ~SPC m r i l~ | insert a unique label |
| ~SPC m r i p~ | add current selection or the word at point to the phrases buffer |
| ~SPC m r i r~ | start a selection process to select a label and insert a reference to it |
| ~SPC m r m t~ | create tags file by running etags on the current document |
| ~SPC m r m b~ | create a new BibTeX database file with all entries referenced in document |
| ~SPC m r n l~ | renumber all simple labels in the document to make them sequentially |
| ~SPC m r p d~ | reparse entire documents |
| ~SPC m r p f~ | parse one file |
| ~SPC m r s a~ | search again |
| ~SPC m r s d~ | produce a list of all duplicate labels in the document |
| ~SPC m r s d~ | regexp search through all files of the current document |
| ~SPC m r s g~ | run grep query through all files related to this document |
| ~SPC m r s q~ | run a query-replace-regexp of FROM with TO over the entire document |
| ~SPC m r v c~ | view cross reference of macro at point |
| ~SPC m r v i~ | display a buffer with an index compiled for the current document |
| ~SPC m r v t~ | display the table of contents for the current document |
| ~SPC m r v T~ | display the table of contents and highlight line corresponding to current position |
| ~SPC m r w~ | save all document buffers |

*** reftex TOC mode

| Key Binding | Description |
|---------------+--------------------------------------------------|
| ~SPC m d~ | demote section at point |
| ~SPC m e t~ | replace current buffer with text of visited file |
| ~SPC m g e~ | switch to TOC of external document |
| ~SPC m g l~ | go to doc location in other window. TOC stays |
| ~SPC m g L~ | doc location in other window. TOC is hidden |
| ~SPC m m d~ | regenerate toc buffer parsing entire document |
| ~SPC m m f~ | regenerate toc buffer parsing file |
| ~SPC m p~ | promote section at point |
| ~SPC m r l~ | rename selected label in TOC |
| ~SPC m t b~ | inclusion of boundaries in toc buffer |
| ~SPC m t i~ | inclusion of index in toc buffer |
| ~SPC m t l~ | inclusion of labels in toc buffer |
| ~SPC m q~ | hide TOC and do not move point |
| ~SPC m v c~ | show where =reftex-toc= was called from |
| ~SPC m v i~ | view index like =reftex-display-index= |
| ~SPC m v l~ | view document location in other window |
13 changes: 2 additions & 11 deletions layers/+lang/latex/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
(spacemacs|defvar-company-backends LaTeX-mode)

(defvar latex-build-command (if (executable-find "latexmk") "LatexMk" "LaTeX")
"The default command to use with `SPC m b'")
"The default command to use with `SPC m c c'")

(defvar latex-enable-auto-fill t
"Whether to use auto-fill-mode or not in tex files.")
Expand All @@ -27,13 +27,4 @@
"align*"
"tabular"
"tikzpicture")
"List of environment names in which `auto-fill-mode' will be inhibited.")

;; Command prefixes
;; no supported
;; (setq auctex/key-binding-prefixes '())
;; (push (cons "mp" "LaTeX Preview") auctex/key-binding-prefixes)
;; (push (cons "mr" "RefTeX") auctex/key-binding-prefixes)
;; (mapc (lambda (x) (spacemacs/declare-prefix (car x) (cdr x)))
;; auctex/key-binding-prefixes)

"List of environment names in which `auto-fill-mode' will be inhibited.")
61 changes: 46 additions & 15 deletions layers/+lang/latex/extensions.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,52 @@

(defun latex/init-emacs-builtin-reftex ()
"Initialize reftex"


(add-hook 'reftex-toc-mode-hook 'turn-on-evil-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX '(nil nil t t t))

(spacemacs/set-leader-keys-for-major-mode 'latex-mode
"rc" 'reftex-citation
"rg" 'reftex-grep-document
"ri" 'reftex-index-selection-or-word
"rI" 'reftex-display-index
"r TAB" 'reftex-index
"rl" 'reftex-label
"rp" 'reftex-index-phrase-selection-or-word
"rP" 'reftex-index-visit-phrases-buffer
"rr" 'reftex-reference
"rs" 'reftex-search-document
"rt" 'reftex-toc
"rT" 'reftex-toc-recenter
"rv" 'reftex-view-crossref))
"ric" 'reftex-citation
"rsq" 'reftex-query-replace-document
"rsg" 'reftex-grep-document
"riI" 'reftex-index-selection-or-word
"rvi" 'reftex-display-index
"rii" 'reftex-index
"ril" 'reftex-label
"rip" 'reftex-index-phrase-selection-or-word
"rgb" 'reftex-index-visit-phrases-buffer
"rir" 'reftex-reference
"rsd" 'reftex-search-document
"ria" 'reftex-index-phrases-apply-to-region ;;
"rvt" 'reftex-toc
"rvT" 'reftex-toc-recenter
"rsd" 'reftex-find-duplicate-labels
"rit" 'reftex-create-tags-file
"rmb" 'reftex-create-bibtex-file
"rpf" 'reftex-parse-one
"rpd" 'reftex-parse-all
"rsa" 'tags-query-replace
"rw" 'reftex-save-all-document-buffers
"rns" 'reftex-renumber-simple-labels
"rgl" 'reftex-goto-label
"rvc" 'reftex-view-crossref)
; =======
; = TOC =
; =======
(spacemacs/set-leader-keys-for-major-mode 'reftex-toc-mode
"vl" 'reftex-toc-view-line
"gl" 'reftex-toc-goto-line
"gL" 'reftex-toc-goto-line-and-hide
"vc" 'reftex-toc-show-calling-point
"q" 'reftex-toc-quit
"p" 'reftex-toc-promote
"d" 'reftex-toc-demote
"rl" 'reftex-toc-rename-label
"vi" 'reftex-toc-display-index
"ge" 'reftex-toc-external
"et" 'revert-buffer
"md" 'reftex-toc-Rescan
"tb" 'reftex-toc-toggle-file-boundary
"tl" 'reftex-toc-toggle-labels
"ti" 'reftex-toc-toggle-index
))
4 changes: 2 additions & 2 deletions layers/+lang/latex/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ the automatic filling of the current paragraph."
;; Rebindings for TeX-font
(defun latex/font-bold () (interactive) (TeX-font nil ?\C-b))
(defun latex/font-medium () (interactive) (TeX-font nil ?\C-m))
(defun latex/font-code () (interactive) (TeX-font nil ?\C-t))
(defun latex/font-typewriter () (interactive) (TeX-font nil ?\C-t))
(defun latex/font-emphasis () (interactive) (TeX-font nil ?\C-e))
(defun latex/font-italic () (interactive) (TeX-font nil ?\C-i))
(defun latex/font-clear () (interactive) (TeX-font nil ?\C-d))
Expand All @@ -58,5 +58,5 @@ the automatic filling of the current paragraph."
(defun latex/font-sans-serif () (interactive) (TeX-font nil ?\C-f))
(defun latex/font-normal () (interactive) (TeX-font nil ?\C-n))
(defun latex/font-serif () (interactive) (TeX-font nil ?\C-r))
(defun latex/font-oblique () (interactive) (TeX-font nil ?\C-s))
(defun latex/font-slanted () (interactive) (TeX-font nil ?\C-s))
(defun latex/font-upright () (interactive) (TeX-font nil ?\C-u))
Loading