From 0a23c30e061c395db3c1314c9382f463d7c9e0db Mon Sep 17 00:00:00 2001 From: UndeadKernel Date: Wed, 11 Apr 2018 13:02:58 +0200 Subject: [PATCH 1/3] Make PDF tools and LaTeX work better together. Update the README file to reflect the available flags. --- modules/lang/latex/README.org | 58 +++++++++++++++++++++++++---------- modules/lang/latex/config.el | 22 +++++++++---- modules/tools/pdf/config.el | 17 ---------- 3 files changed, 58 insertions(+), 39 deletions(-) diff --git a/modules/lang/latex/README.org b/modules/lang/latex/README.org index 620669f40..7bdc815e7 100644 --- a/modules/lang/latex/README.org +++ b/modules/lang/latex/README.org @@ -26,28 +26,54 @@ Set these variables in your private configuration with: #+END_SRC If the variables are not set, they are ignored. +** Choose View Program +You have four options to choose from for the viewer of your PDF rendered files. +*** Okular +Use Okular as default PDF viewer. + +Activate with the flag '+okular' of the latex module in your private init.el. +#+BEGIN_SRC emacs_lisp +(latex +okular) +#+END_SRC + +*** Skim +For Mac users. Use Skim to preview your PDFs. + +Activate with the flag '+skim' of the latex module in your private init.el. +#+BEGIN_SRC emacs_lisp +(latex +skim) +#+END_SRC + +*** PDF Tools +Use the PDF Tools package to preview your PDFs. Requires the tools module ~pdf~ enabled in your configuration. +#+BEGIN_SRC emacs_lisp +(:tools pdf) +#+END_SRC + +Activate with the flag '+pdf-tools' of the latex module in your private init.el. +#+BEGIN_SRC emacs_lisp +(latex +pdf-tools=) +#+END_SRC + +*** Preview Pane +You may wish to use the old school package ~latex-preview-pane~ instead of the +other alternatives. ~latex-preview-pane~ uses a ~DocView~ instead. + +Activate with the flag '+preview-pane' of the latex module in your private init.el. +#+BEGIN_SRC emacs_lisp +(latex +preview-pane) +#+END_SRC + ** LatexMk -Use LatexMk instead of normal LaTeX to compile documents. LatexMk only needs to run once to get all references, bibliography and other things right. +Use LatexMk instead of normal LaTeX to compile documents. LatexMk only needs to +run once to get all references, bibliography and other things right. Activate with the flag '+latexmk' of the latex module in init.el. #+BEGIN_SRC emacs_lisp (latex +latexmk) #+END_SRC -** Okular -Use Okular as default PDF viewer. - -Activate with the flag '+okular' of the latex module in init.el. +You can enable both a custom view program and LatexMk with a call such as: #+BEGIN_SRC emacs_lisp -(latex +okular) -#+END_SRC - -** Preivew-Pane -Instead of using an external program to display rendered .tex files, use an emacs window to display the rendered file. - -This flag is incompatible with the ~+okular~ flag. - -Activate with the flag '+preview-pane' of the latex module in init.el. -#+BEGIN_SRC emacs_lisp -(latex +preview-pane) +(latex +latexmk +okular) #+END_SRC diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index f0a85e9d0..61b877c43 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -103,21 +103,31 @@ LaTeX-indent-environment-list)))) (after! latex - ;; Use Okular is the user says so. + ;; Use Okular if the user says so. (when (featurep! +okular) ;; Configure Okular as viewer. Including a bug fix ;; (https://bugs.kde.org/show_bug.cgi?id=373855) (add-to-list 'TeX-view-program-list '("Okular" ("okular --unique file:%o" (mode-io-correlate "#src:%n%a")))) (add-to-list 'TeX-view-program-selection - '(output-pdf "Okular")))) + '(output-pdf "Okular"))) -(after! latex + ;; Or Skim (when (featurep! +skim) (add-to-list 'TeX-view-program-list '("Skim" "/Applications/Skim.app/Contents/SharedSupport/displayline -b -g %n %o %b")) (add-to-list 'TeX-view-program-selection - '(output-pdf "Skim")))) + '(output-pdf "Skim"))) + + ;; Or PDF-tools, but only if the module is also loaded + (when (and (featurep! :tools pdf) (featurep! +pdf-tools)) + (add-to-list 'TeX-view-program-list + '("PDF Tools" ("TeX-pdf-tools-sync-view"))) + (add-to-list 'TeX-view-program-selection + '(output-pdf "PDF Tools")) + ;; Enable auto reverting the PDF document with PDF Tools + (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer))) + (def-package! preview @@ -136,6 +146,8 @@ reftex-toc-split-windows-fraction 0.3) (unless (string-empty-p +latex-bibtex-file) (setq reftex-default-bibliography (list (expand-file-name +latex-bibtex-file)))) + (add-hook! (latex-mode LaTeX-mode) #'turn-on-reftex) + :config ;; Get ReTeX working with biblatex ;; http://tex.stackexchange.com/questions/31966/setting-up-reftex-with-biblatex-citation-commands/31992#31992 (setq reftex-cite-format @@ -146,8 +158,6 @@ (?f . "\\footcite[]{%l}") (?n . "\\nocite{%l}") (?b . "\\blockcquote[]{%l}{}"))) - (add-hook! (latex-mode LaTeX-mode) #'turn-on-reftex) - :config (map! :map reftex-mode-map :localleader :n ";" 'reftex-toc) (add-hook! 'reftex-toc-mode-hook diff --git a/modules/tools/pdf/config.el b/modules/tools/pdf/config.el index 55eb60b70..ee11260f1 100644 --- a/modules/tools/pdf/config.el +++ b/modules/tools/pdf/config.el @@ -12,20 +12,3 @@ (setq-default pdf-view-display-size 'fit-page) ;; turn off cua so copy works (add-hook! 'pdf-view-mode-hook (cua-mode 0))) - - -(when (featurep! :lang latex) - (after! latex - ;; add to the program list - (add-to-list 'TeX-view-program-selection - '(output-pdf "PDF Tools")) - (add-to-list 'TeX-view-program-list - '("PDF Tools" ("TeX-pdf-tools-sync-view"))) - - ;; enable document revert - (add-hook 'TeX-after-compilation-finished-functions - #'TeX-revert-document-buffer) - - ;; correlated mode - (setq TeX-source-correlate-start-server t - TeX-source-correlate-mode t))) From 717f6e3cfe40472d5a818eff9b9c7542386d5dbb Mon Sep 17 00:00:00 2001 From: UndeadKernel Date: Wed, 11 Apr 2018 13:03:59 +0200 Subject: [PATCH 2/3] Sneak in some more nice-to-have LaTeX fontifications. --- modules/lang/latex/+fontification.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/lang/latex/+fontification.el b/modules/lang/latex/+fontification.el index fa853e726..627931543 100644 --- a/modules/lang/latex/+fontification.el +++ b/modules/lang/latex/+fontification.el @@ -8,6 +8,8 @@ ("addbibresource" "[{") ;; Standard commands ("cite" "[{") + ("citep" "[{") + ("citet" "[{") ("Cite" "[{") ("parencite" "[{") ("Parencite" "[{") From 12fd06d4e6f679237e4c61b13fedfdfbe3fc6e8a Mon Sep 17 00:00:00 2001 From: UndeadKernel Date: Thu, 12 Apr 2018 16:03:48 +0200 Subject: [PATCH 3/3] Uncluttered custom modeline to show page numbers Add rules to handle windows that should not be considered as popups. --- modules/tools/pdf/+modeline.el | 10 ++++++++++ modules/tools/pdf/config.el | 16 ++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 modules/tools/pdf/+modeline.el diff --git a/modules/tools/pdf/+modeline.el b/modules/tools/pdf/+modeline.el new file mode 100644 index 000000000..eb0acb7bd --- /dev/null +++ b/modules/tools/pdf/+modeline.el @@ -0,0 +1,10 @@ +;;; tools/pdf/+modeline.el -*- lexical-binding: t; -*- + + +(def-modeline-segment! +pdf-tools-pages + "Current and total page indicator for PDF documents." + (format " P %d/%d" (pdf-view-current-page) (pdf-cache-number-of-pages))) + +(def-modeline! pdf-tools-modeline + (bar matches " " buffer-info +pdf-tools-pages) + (major-mode vcs)) diff --git a/modules/tools/pdf/config.el b/modules/tools/pdf/config.el index ee11260f1..c0fcabf3d 100644 --- a/modules/tools/pdf/config.el +++ b/modules/tools/pdf/config.el @@ -9,6 +9,18 @@ (map! :map pdf-view-mode-map "q" #'kill-this-buffer) + ;; Fit pages to screen by default (setq-default pdf-view-display-size 'fit-page) - ;; turn off cua so copy works - (add-hook! 'pdf-view-mode-hook (cua-mode 0))) + ;; Turn off cua so copy works + (add-hook! 'pdf-view-mode-hook (cua-mode 0)) + ;; Custom modeline that removes useless info and adds page numbers + (when (featurep! :ui doom-modeline) + (load! +modeline) + (add-hook! pdf-tools-enabled (doom-set-modeline 'pdf-tools-modeline))) + ;; Handle PDF-tools related popups better + (set! :popup "^\\*Outline*" '((side . right) (size . 40)) '((select))) + ;; TODO: Add additional important windows that should be handled differently + ;; TODO: These two next rules don't work (they should), investigate + ;; (set! :popup "\\*Contents\\*" '((side . right) (size . 40)) nil) + ;; (set! :popup "* annots\\*$" '((side . left) (size . 40)) '((select))) + )