Inline citation doesn't popup in subfiles
See original GitHub issueForeword: I originally wrote the issue up as a bug report because I was trying to track down a bug. I have now found a “solution” to the bug, but said solution is quite inconvenient.
Disable all the other extensions except for LaTeX Workshop, and check that you still see this issue. [Required]
You still see this issue?: Yes
Describe the bug [Required]
Intellisense does not pop-up with citation key suggestions in one of my LaTeX projects. Specifically, a project that uses subfiles. See the “Additional Context” section below for more details.
To Reproduce Steps to reproduce the behavior:
- Go to existing project
- Start typing in “\cite{”
- Hit ‘Enter’ to autocomplete and bring up the intellisense “suggestions” (idk what to call it)
- Start typing in citation key, but it does not come up
Expected behavior
Intellisense to show the citation keys and insert them. This is done on a single files LaTeX project using the same .bib
file.
Logs [Required] This log is after reloading the VS Code window with nothing but LaTeX Workshop extension loaded, and immediately performing the reproduction steps.
LaTeX Workshop Output [Required]
[13:15:32] Initializing LaTeX Workshop. [13:15:32] pdflatex is provided by MiKTeX [13:15:32] Creating LaTeX Workshop http and websocket server. [13:15:32] LaTeX Workshop initialized. [13:15:32] Linter for root file started. [13:15:32] Found root file from active editor: c:\Users\jrwrigh\gitRepos\ms_thesis\background.tex [13:15:36] Root file changed from: undefined. Find all dependencies. [13:15:36] Instantiating a new file watcher for c:\Users\jrwrigh\gitRepos\ms_thesis\background.tex [13:15:36] Parsing c:\Users\jrwrigh\gitRepos\ms_thesis\background.tex [13:15:36] Cannot find file c:\Users\jrwrigh\gitRepos\ms_thesis\background.fls [13:15:36] Server created on 127.0.0.1:62975 [13:15:36] Snippet data loaded. [13:15:36] LaTeX Workshop version: 7.0.2Developer Tools Console [Required]
Nothing suspiciousScreenshots See explanatory gifs above
Desktop [Required]:
- OS: Windows 10
- VS Code version: 1.35.1
- Extension version: 7.0.2
IMPORTANT CONTEXT/Solution
The thesis is a subfiles-based project. So it each subfile does not have a \bibliography{[.bib file]}
command on it. Instead, I have a command defined in the “main” .tex
file that makes the subfiles package compile correctly:
\def\biblio{\bibliographystyle{new-aiaa}\bibliography{Sources}}
If I add a \bibliographystyle{new-aiaa}\bibliography{Sources}
line to the end of the subfile, then the intellisense works. However, I’d much prefer to keep this single command in main.tex
as it’s much easier to switch between biliography styles this way.
Possible Feature Suggestion Is it possible to force a bib file to be used as intellisense? Like a magic command:
% !TEX bibfile = relative/or/absolute/path/to/bibfile.bib
I know there is latex-workshop.latex.bibDirs
already available, but I thought that it would check the current directory for .bib
files, My project has the subfile and .bib
in the same directory.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
When a root file is detected (see the wiki), it is parsed and all the included files recursively to detect bibliographies via
\addbibresource
or\bibliography
. Then, every.bib
file is associated to all files in the current LaTeX project to provide intellisense. Then, the problem arises withsubfiles
, because eachsubfile
has its own\documentclass[...]{subfiles}
command and is therefore considered as a root file. So, if you comment the line\documentclass[./mainMWE.tex]{subfiles}
insection.tex
, everything works as expected.I will think of a way to properly handle the subfiles package.
I am too facing the same issue — the intellisense citation-key autocomplete is not working on sub-files.
I have similar setup as reported by @jrwrigh — I have the main tex-config file in which I have put all the tex configurations; and each tex files imports this main tex-config file.