Rapiz · 2022-08-30 13:01
Hello fellas,
I'm using Arch Linux and every time I compile, I have to open the PDF with Brave.
Here [https://wiki.archlinux.org/title/PDF,\_PS\_and\_DjVu](https://wiki.archlinux.org/title/PDF,_PS_and_DjVu) it seems like there are PDF engines, viewers etc, but I don't understand what to do :D
Any suggestions on how I can automate this?
Have a nice day!
Edit:
TLDR If you are using Arch Linux you need [https://aur.archlinux.org/packages/emacs-pdf-tools-git](https://aur.archlinux.org/packages/emacs-pdf-tools-git) to fix the issue for pdf-tools-install.
ppvvaa · 2022-08-30 13:47
I use `pdf-tools` and it just opens the pdf in another emacs window. You can move the focus to that window using `C-c C-v`. Here is what I have in my config file related to this, which works just great for me.
(use-package pdf-tools
:init
(pdf-tools-install)
:config
(setq TeX-view-program-selection '((output-pdf "PDF Tools"))
TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view))
TeX-source-correlate-start-server t)
(add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer)
(setq pdf-view-use-scaling t)
(setq pdf-view-resize-factor 1.05)
:bind (:map pdf-view-mode-map
("<left>" . pdf-view-previous-page-command)
("<right>" . pdf-view-next-page-command)))
NOTE: pdf-tools must be installed through melpa, there is another version available by default which does not work for me, so your config file should include
(require 'package)
(add-to-list 'package-archives '("melpa" . "[https://melpa.org/packages/](https://melpa.org/packages/)") t) (package-initialize)
and for AUCTeX, although I think the only thing here related to the pdf preview is the first line, to allow for syncing between source and pdf:
(setq TeX-source-correlate-mode t)
(setq font-latex-fontify-script nil)
(setq reftex-extra-bindings t) ;; Must be befor require reftex! (require 'reftex) (add-hook 'LaTeX-mode-hook 'turn-on-reftex) (add-hook 'LaTeX-mode-hook (lambda() (display-line-numbers-mode 1))) (add-hook 'LaTeX-mode-hook (lambda() (visual-line-mode 1))) (setq reftex-plug-into-auctex t)
;; magic words: (setq reftex-label-alist '((nil ?e nil nil nil ("system" "systems" "estimate" "estimates")))) (setq TeX-save-query nil)
PhantomSeahorse · 2022-08-30 14:00
C-c C-a
Rapiz · 2022-08-30 14:10
Thanks! I have installed pdf-tools through the package manager.
Do I still need to set all this stuff?
I am currently writing it into my config, but after TeX-revert the code is still marked red somehow?
I've tried
(setq TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view))
TeX-view-program-selection '((output-pdf "PDF Tools"))
TeX-source-correlate-start-server t)
but C-c C-a from u/PhantomSeahorse returns that Evince viewer is selected and can not find it.
Rapiz · 2022-08-30 14:10
With this I get that Evince is missing, I guess I have to set pdf-tools the viewer manually.
PhantomSeahorse · 2022-08-30 14:12
Yes. Do that and it should work. Note that C-c C-a opens up a new window of the viewer each time tho
ppvvaa · 2022-08-30 14:19
Do you have use-package installed?
Make sure that you installed the pdf-tools version from melpa.
You don't need to set all this stuff, some of it is just configs that I like, but I think you do need the party where it sets pdf-tools to be the default pdf viewer.
I'm not sure what it means that the code is "marked red"...
Rapiz · 2022-08-30 14:23
marked as string like "Random Text Example"
But isn't it enough to have it installed through the package manager?
It is currently just the selection of PDF Tools as default, that is off because it's Evince.
Currently I don't know what use-package is :D
Rapiz · 2022-08-30 14:46
Update:
I had to restart emacs :D
(setq TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view))
TeX-view-program-selection '((output-pdf "PDF Tools"))
TeX-source-correlate-start-server t)
With this C-c C-a opens the pdf with pdf-tools by the pdf-tools from emacs package manager.
also added the following to remove the welcome shit.
(setq inhibit-startup-message t)
Thanks for the help! Enjoy the week :D
ppvvaa · 2022-08-30 15:28
Glad you could make it work!
use-package is a package for managing packages. You don't need to have it, but many packages require some setup (like what you're doing here with pdf-tools) and often, looking for installation instructions on the internet for some package that interests you, you'll find those setup options written using use-package, so it can make configuration easier.
Rapiz · 2022-08-30 20:42
It didn't work. I thought it did, but it was another viewer with low quality.
I had to install the arch linux pdf-tools, copy your init and now it works!