lervag / vimtex

VimTeX: A modern Vim and neovim filetype plugin for LaTeX files.
MIT License
5.5k stars 389 forks source link

Compilation doesn't update PDF #2979

Closed andreasschaab closed 3 months ago

andreasschaab commented 3 months ago

Description

My issue is simple to explain (and possibly related to Issue #496):

I am new to all of this, so I apologize in advance if I am making a silly mistake. I've been looking at other related issues and tried reproducing suggested solution steps, but after two days testing this it doesn't work. Thank you SO much in advance for any help!

Steps to reproduce

Modified .tex file:

\documentclass{article}
\begin{document}

Hello, World!

Hello it's me
\end{document}

.vimrc file:

set nocompatible

" Set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" Let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'lervag/vimtex'

call vundle#end()
filetype plugin indent on

syntax enable

" VimTeX settings
let g:vimtex_view_method = 'skim'
let g:vimtex_compiler_method = 'latexmk'

let g:vimtex_view_skim_sync = 1
let g:vimtex_view_skim_activate = 1
let g:vimtex_view_general_viewer = 'open -a Skim'
let g:vimtex_view_general_options = '--args -r'

I also add the output of \lo after the second \ll (which says it compiled):

Rc files read:
  NONE
Latexmk: This is Latexmk, John Collins, 31 Jan. 2024. Version 4.83.
======= Need to update make_preview_continuous for target files
Not using a previewer
------------
Running 'echo vimtex_compiler_callback_compiling'
------------
vimtex_compiler_callback_compiling
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex':  Reasons for rerun
Changed files or newly in use/created:
  test.tex
Category 'changed_user':
  test.tex

------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex  -file-line-error -synctex=1 -interaction=nonstopmode -recorder  "test.tex"'
------------
This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2023-11-01> patch level 1
/var/folders/6b/vl8fcz6x2h5dfk5dcrsz8hvw0000gn/T/vQzoVKS/0      

Pressing \li results in:

Error detected while processing function vimtex#info#open[2]..vimtex#scratch#new[2]..224:
line    4:
E37: No write since last change (add ! to override)

Expected behavior

PDF should be updated after pressing \ll once, and Skim should display the updated file

Actual behavior

First \ll doesn't compile, second \ll says it compiled but the PDF doesn't change

Do you use a latexmkrc file?

I deleted it for this test

VimtexInfo

System info:
  OS: macOS 14.5 (23F79)
  Vim version: VIM 9.1 (1-550)
  Has clientserver: false

VimTeX project: test
  base: test.tex
  root: /Users/andreasschaab
  tex: /Users/andreasschaab/test.tex
  main parser: current file verified
  document class: article
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
  viewer: Skim
  qf method: LaTeX logfile
lervag commented 3 months ago
  • I create a minimal test.tex file and make sure to run latexmk -C test.tex

  • Running vim test.tex followed by \ll compiles correctly and produces a PDF that is displayed in Skim

  • But then I modify the .tex file by adding a new line "Hello it's me". Pressing \ll again yields "VimTeX: Compiler stopped (test.tex)"

Why did you press \ll again? You don't need to. After you add a new line and then save the file with :w, latexmk will recompile the file. The first \ll will start latexmk wich will run in the background and compile the file whenever it changes.

  • When I then press \ll again a second time, it says "compilation completed" but the PDF has not been updated. This is the core of my issue. Skim still displays the original, unmodified PDF, and the PDF file itself also remains unaltered.

You need to save the file for it to recompile. It is not enough to just restart the compiler with \ll.

I am new to all of this, so I apologize in advance if I am making a silly mistake.

No need to apologize - we are all new at some point. I'm happy to help!

.vimrc file: …

If you use Vundle, it seems (from the main README of Vundle.vim) that you also need filetype off after set nocompatible. Next, you don't need to set VimTeX options unless you change them from their default value. And the general viewer is not relevant when you specify to use Skim. So, you should update your config to this:

set nocompatible
filetype off

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'VundleVim/Vundle.vim'
Plugin 'lervag/vimtex'

call vundle#end()
filetype plugin indent on
syntax enable

" VimTeX settings
let g:vimtex_view_method = 'skim'
let g:vimtex_view_skim_sync = 1
let g:vimtex_view_skim_activate = 1

Pressing \li results in:

Error detected while processing function vimtex#info#open[2]..vimtex#scratch#new[2]..224:
line    4:
E37: No write since last change (add ! to override)

This error message appears because \li opens a new buffer and your previous buffer was modified and not saved. I strongly suggest that you add set hidden in your vimrc and that you learn about buffers. See :help buffers.

andreasschaab commented 3 months ago

Thank you so, so much for these clarifications!!! I am genuinely so grateful that you took the time to answer. It's really kind of you and I really appreciate it. It's all working now. I updated my vimrc as you suggested. I want to apologize again for asking such a beginner question as I'm just getting started with all this. But again, thank you so so much :)

lervag commented 3 months ago

Thank you so, so much for these clarifications!!! I am genuinely so grateful that you took the time to answer. It's really kind of you and I really appreciate it. It's all working now. I updated my vimrc as you suggested. I want to apologize again for asking such a beginner question as I'm just getting started with all this. But again, thank you so so much :)

Glad to hear it was useful and appreciated! And good luck on your journey to learn Vim!