ROCKTAKEY / lsp-latex

Emacs lsp-mode client for LaTeX, on texlab.
GNU General Public License v3.0
66 stars 4 forks source link

Question: How to set the viewer in tex-mode #32

Closed onekk closed 3 years ago

onekk commented 3 years ago

Thanks for this package, it permits to use texlab on emacs.

I was finding a substitute for vscode on Linux to compile latex file.

I have found a way to launche arara and compile the file.

Now I'm trying to launch the preview with Zathura to check the document and make the forward search form the pdf viewer.

and maybe a way to make the search from the Tex file to the zathura istance (I'm bit confused about the search terminology).

After having searched around, i will find some information for AUCTEX but nothing about texlab.

Any hints?

Regards

Carlo D.

ROCKTAKEY commented 3 years ago

Thanks for your issue. See here. The doc is for VSCode.

{
  "texlab.forwardSearch.executable": "zathura",
  "texlab.forwardSearch.args": ["--synctex-forward", "%l:1:%f", "%p"]
}

You can use lsp-latex-forward-search-executable as "texlab.forwardSearch.executable", lsp-latex-forward-search-args as "texlab.forwardSearch.args". So write like this in init.el:

(setq lsp-latex-forward-search-executable "zathura")
(setq lsp-latex-forward-search-args '("--synctex-forward" "%l:1:%f" "%p"))
onekk commented 3 years ago

Many thanks, I've seen similar solution, but I have problem doing these things:

1) how to fire the viewer after having compiled the sources, some shortcut to a sequence of keys could be useful 2) when opened the viewer, how to go to the portion of code from emacs to zathura 3) how to go from zathura to emacs source documents (I generally use a multicoduments, splitted in chapters so the main doc has \include())

for point 3, I've in zathurarc code for vscode:

set synctex true set synctex-editor-command "code -r -g %{input}:%{line}" I've found something around:

set synctex-editor-command "emacsclient +%{line} %{input}"

EDIT: I've tested pdf-tools but it is consuming a lot of memory and it's slow.

TIA and Regards

Carlo D.

ROCKTAKEY commented 3 years ago
  1. how to fire the viewer after having compiled the sources, some shortcut to a sequence of keys could be useful

AFAIK, there is no specific command provided by texlab or Emacs. A new function should defined for each viewer.

  1. when opened the viewer, how to go to the portion of code from emacs to zathura

Run lsp-latex-forward-search.

  1. how to go from zathura to emacs source documents (I generally use a multicoduments, splitted in chapters so the main doc has \include())

for point 3, I've in zathurarc code for vscode:

set synctex true set synctex-editor-command "code -r -g %{input}:%{line}" I've found something around:

set synctex-editor-command "emacsclient +%{line} %{input}"

EDIT: I've tested pdf-tools but it is consuming a lot of memory and it's slow.

Yes, like this document,

"emacsclient +%{line} %{input}"

should work. (-c is not needed. It just creates new frame.)

onekk commented 3 years ago

Ok many thanks, I've solved:

1) and 2) using a redefined sequence to launch zathura and settin the proper variable for texlab

;; set C-c f to latex forward search
(eval-after-load 'tex-mode
    '(define-key latex-mode-map (kbd "C-c f") 'lsp-latex-forward-search))

(setq lsp-latex-forward-search-executable "zathura")
(setq lsp-latex-forward-search-args    
      '("--synctex-forward" "%l:1:%f" "%p"))

3)

a server has to be start (I could have guessed from "emacsclient" line as a client need a server) so i put in my init.el

;; start a server 
(server-start) 

and in zathurarc as you confirmed me

set synctex-editor-command "emacsclient +%{line} %{input}"

So everything is working fine at least with emacs an zathura for Arch Linux.

Maybe some wiki pages could help other users?

Many thanks and Regards

Carlo D.

ROCKTAKEY commented 3 years ago

a server has to be start (I could have guessed from "emacsclient" line as a client need a server)

Yes, server should be started.

Maybe some wiki pages could help other users?

I think so, too. I will add description about forward search to README. Thanks!

ROCKTAKEY commented 3 years ago

Added forward/inverse search instruction to README.

ROCKTAKEY commented 3 years ago

Please reopen this issue if there are any other questions.