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

VimtexTocOpen sometimes adds a spurious extension to filenames #2126

Closed
alexandreroberts opened this issue Aug 6, 2021 · 8 comments
Closed

Comments

@alexandreroberts
Copy link

alexandreroberts commented Aug 6, 2021

I am experiencing an issue similar to this one: sometimes (not always) :VimtexTocOpen adds a spurious .tex to the end of filenames; for example, the line \import{FILEPATH}{general.header.tex} results in a TOC entry tex incl: general.header.tex.tex.

Relatedly, sometimes it ignores FILEPATH in the command \import{FILEPATH}{FILENAME}, printing only FILENAME rather than FILEPATH/FILENAME.

So the issue seems to be how vimtex parses \import commands. Curiously, it sometimes works and sometimes does not work. I haven't been able to discern what is different about those cases (they all involve the same FILEPATH, which reads, in my case /Users/alexandre/Dropbox/TeX-Alex-custom-files/).

The reason I noticed this problem is that it makes vimtex sometimes unaware of the .bib files I load, thus making citation completion not work.

Output from VimtexInfo

System info
  OS: Mac OS X 10.15.6 (19G2021)
  Vim version: NVIM v0.5.0
  Has clientserver: true
  Servername: /var/folders/92/6c80fs_55hnf_1s2ybgbv5c40000gn/T/nvim5VO5rw/0

vimtex project: _souda-chemeia
  base: _souda-chemeia.tex
  root: /Users/robe941/Dropbox/Projects/1c-ABOUT-TO-SUBMIT/souda-chemeia-AlchByzVol
  tex: /Users/robe941/Dropbox/Projects/1c-ABOUT-TO-SUBMIT/souda-chemeia-AlchByzVol/_souda-chemeia.tex
  out: /Users/robe941/Dropbox/Projects/1c-ABOUT-TO-SUBMIT/souda-chemeia-AlchByzVol/_souda-chemeia.pdf
  log: /Users/robe941/Dropbox/Projects/1c-ABOUT-TO-SUBMIT/souda-chemeia-AlchByzVol/_souda-chemeia.log
  aux: /Users/robe941/Dropbox/Projects/1c-ABOUT-TO-SUBMIT/souda-chemeia-AlchByzVol/_souda-chemeia.aux
  fls: 
  tex program: xelatex
  source files:
    _souda-chemeia.tex
    sections/0-to-add.tex
    sections/1-intro.tex
    sections/2-body.tex
    sections-compiled-by-Makefile.tex
    sections/3-conclusion.tex
    _outline.tex
  compiler: latexmk
    backend: nvim
    output: /var/folders/92/6c80fs_55hnf_1s2ybgbv5c40000gn/T/nvim5VO5rw/1
    configuration: 
      continuous: 1
      callback: 1
      latexmk options:
        -verbose
        -file-line-error
        -synctex=1
        -interaction=nonstopmode
      latexmk engine: -xelatex
  viewer: General
  qf: LaTeX logfile
    config: 
      packages: 
        default: 1
      default: 1
  document class: memoir
  packages:
    chemformula
    geometry
    import
@lervag
Copy link
Owner

lervag commented Aug 6, 2021

So the issue seems to be how vimtex parses \import commands. Curiously, it sometimes works and sometimes does not work. I haven't been able to discern what is different about those cases (they all involve the same FILEPATH, which reads, in my case /Users/alexandre/Dropbox/TeX-Alex-custom-files/).

It is very difficult to debug a problem if I can't reproduce it. Could you try to find a reliable manner in which you can reproduce the problem you are experiencing and provide a minimal example?

@alexandreroberts
Copy link
Author

alexandreroberts commented Aug 7, 2021

Edit: @lervag has updated this comment to inline the minimal example.

Given the following files:

/some/path/
├── main.tex
├── other-dir
│   └── file-that-calls-bib-file.tex
└── test.bib

With the following contents:

main.tex

\documentclass[12pt,article,draft]{memoir}
\usepackage{import}

\import{/some/path/other-dir/}{file-that-calls-bib-file.tex}

\begin{document}
Hello.
\end{document}

other-dir/file-that-calls-bib-file.tex

\usepackage{biblatex-chicago}
\addbibresource{/some/path/test.bib}

test.bib

@book{testkey,
  author = {Me},
  title = {A Book},
  year = {2021}
}

If you open main.tex and run VimtexTocOpen on it, you will see the issue (or at least I do on my computer).

Repository owner deleted a comment from alexandreroberts Aug 8, 2021
Repository owner deleted a comment from alexandreroberts Aug 8, 2021
Repository owner deleted a comment from alexandreroberts Aug 8, 2021
Repository owner deleted a comment from alexandreroberts Aug 8, 2021
Repository owner deleted a comment from alexandreroberts Aug 8, 2021
Repository owner deleted a comment from alexandreroberts Aug 8, 2021
@lervag
Copy link
Owner

lervag commented Aug 8, 2021

First: I took the liberty of cleaning up your comments by inlining the example and deleting the unnecessary content. This helps me quickly refresh the context when I again consider the issue.

Thank you for providing a minimal example! However, I still can't reproduce any issues. Can you

  1. Check that I did not misunderstand anything by reading the updated minimal example in your comment.

  2. Provide your relevant VimTeX configuration. (Or, better - provide a fully minimal vimrc file so that the reproduction step becomes vim -u test.vim main.tex.)

  3. You write:

    If you open main.tex and run VimtexTocOpen on it, you will see the issue (or at least I do on my computer).

    Can you be specific here: What does "you will see the issue" mean?

@alexandreroberts
Copy link
Author

Thank you, I wasn't sure what information might be useful, but it is certainly clearer without every step in my thought-process.

Here is a minimal vimrc file:

test.vim

call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex' 
call plug#end()

The issue

The issue is that when I open main.tex by running nvim -u test.vim main.tex (note that I am using NeoVim -- not sure if that makes a difference) and then run :VimtexTocOpen, I get the following output:

Screen Shot 2021-08-08 at 3 14 04 PM

There are actually two problems with the output.

The first is that the list of Included files in the TOC has only one entry, for file-that-calls-bib-file.tex. But based on the files, the TOC ought to include test.bib as well, since other-dir/file-that-calls-bib-file.tex calls test.bib.

If you widen the TOC, you see the second problem: the single entry in the TOC reads file-that-calls-bib-file.tex.tex, with an extra .tex extension.

Maybe these two issues are related?

@lervag
Copy link
Owner

lervag commented Aug 12, 2021

Thanks for the update! I've tested with the test files provided by you. I have used the following structure:

pwd
# /home/lervag/.local/plugged/vimtex/test/issues/2126

tree
# .
# ├── main.tex
# ├── sub
# │   └── imported.tex
# ├── test.bib
# └── test.vim

Where the contents of the files are as specified by you, except with the paths changed according to the above file names and locations.

I now open with nvim -u test.vim main.tex, then do \lt to open the ToC. It looks like this:

image

As you can see, everything looks right. Can you test with a similar structure as the one I've used here (change the file names accordingly, and so on)? Perhaps I'm missing a minor detail?

@j1-lee
Copy link
Contributor

j1-lee commented Aug 18, 2021

At the line \import{/some/path/other-dir/}{file-that-calls-bib-file.tex} in main.tex, omitting / at the end of /some/path/other-dir/, as in the OP's screenshot, seems to exclude test.bib.

Whether this slash can be omitted depends on the version of the package: https://tex.stackexchange.com/questions/44480/using-import-correctly

lervag added a commit that referenced this issue Aug 18, 2021
lervag added a commit that referenced this issue Aug 18, 2021
@lervag
Copy link
Owner

lervag commented Aug 18, 2021

Ah, yes: From 2020, the import package allows to remove the trailing /. So, in this case, there's no reason not to allow it in VimTeX.

I've fixed this now.

@lervag lervag closed this as completed Aug 18, 2021
@alexandreroberts
Copy link
Author

That fixed it -- thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants