2

Currently writing my thesis using LateX, I'm trying to obtain autocomplete on my citations when writing the chapters. The directory structure is that each chapter has its own main.tex files (template from university). The main (thesis.tex) file has the following relevant entries:

\documentclass[%
twoside, openright, titlepage, numbers=noenddot,%
cleardoublepage=empty,%
abstractoff,%
BCOR=5.5mm, paper=a5, fontsize=10pt,% A5 soft cover
%BCOR=5.5mm, paper=17cm:24cm, fontsize=10pt,% 17 cm x 24 cm
%BCOR=5mm, paper=15.59cm:23.39cm, fontsize=10pt,% Royal soft cover %BCOR=0mm, paper=15.24cm:22.86cm, fontsize=10pt,% US-Trade hard cover
 10 ]{scrreport}

\addbibresource{bibliography.bib}

\cleardoublepage\pagenumbering{arabic}
\def\dir{chapters/introduction}
\include{\dir/main} 

\cleardoublepage%
\def\dir{chapters/chapter2_theory}
\include{\dir/main} 

\cleardoublepage%
\def\dir{chapters/chapter3_EVOH}
\include{\dir/main}

The bibliography.bib file is in the same thesis.tex file.

For autocomplete I am using coc.nvim setup with digestif as described here. I also installed vimtex.

While autocompletion for the citations works perfectly with my thesis.tex file (with \cite{}), for each chapter main.tex file (where it is the most important), it does not work. I already copied the bibliography.bib file to each chapter directory and still cannot see the autocomplete.

4
  • 3
    From the VimTeX perspective: The use of your custom \dir macro makes it impossible for VimTeX to parse the project correctly. If you instead simply did \include{chapters/chapter2_theory/main} and similar, I believe things should work as expected. Jun 4, 2022 at 11:06
  • Indeed, I see what happened here. Issue is resolved, thank you!
    – Jeanot
    Jun 4, 2022 at 11:39
  • @KarlYngveLervåg can you add that as an answer? Alternately, Jeanot can answer with how they resolved the issue. (Or both :) )
    – D. Ben Knoble
    Jun 4, 2022 at 12:35
  • Ok, will do. Did not feel it was enough of an answer at first. :) Jun 5, 2022 at 9:40

1 Answer 1

2

You are describing a situation where you are working on a LaTeX project that consists of multiple files with a master file that includes the chapters. The cite completion you are asking about is a feature provided by VimTeX with its omnicomplete function. coc.nvim is used to provide the autocomplete part, but it is not relevant here.

To provide completion for citations, VimTeX needs to know the location of you bibliography file. This is specified with \addbibresource. Thus, the feature relies on VimTeX knowing the master file of your project when you are working in the included files. VimTeX implements several methods for locating the master file, see :help vimtex-multi-file. The default method, "Recursive search", usually works very well in most cases. However, you provide an example that is not supported:

\def\dir{chapters/introduction}
\include{\dir/main}

When VimTeX is started in the introduction/main.tex file, it will look for files that include it with \include or \input. But VimTeX does not handle custom macro \dir that you use. So, to make it work automatically, you should simplify to this:

\include{chapters/introduction/main}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.