Setup
I have the following folder structure:
home/ A/ A.tex C.tex B/ B.tex C.tex and the file contents are as follows
home/A/A.tex
\input{../B/B.tex} home/B/B.tex
\documentclass{article} \begin{document} Hello from B! \input{C.tex} \end{document} home/A/C.tex
Hello from A/C! home/B/C.tex
Hello from B/C! Result
As mentioned in the title, I'm using the LaTeX Workshop in VSCode. When I run A/A.tex, I expect it to create A/A.pdf which displays
Hello from B! Hello from A/C! However, it does not do that! Instead, it creates B/B.pdf which displays
Hello from B! Hello from B/C! which is not what I expect and not what I need. It seems as if VSCode automatically changes the input path to that of B/B.tex.
Some research
I noticed this doesn't happen in Texmaker. Also, if I temporarily change the content of A/A.tex to what's displayed below, then the input path resolves itself and I obtain A/A.pdf.
% \input{../B/B.tex} \documentclass{article} \begin{document} Hello from A! \end{document} I then undo these changes, then compile A/A.tex again and then I do obtain the A/A.pdf with the expected content!
What's more, the editor tab in VSCode displays the input path (I think?) and it's updated as mentioned above:
To me, it is a lot of indication that it's VSCode, or LaTeX Workshop, and not LaTeX that does a lot of automatic resolving of input paths, which I do not want/need.
Question
Why does it do this and how can I resolve it? How can I ensure that VSCode always creates the PDF corresponding to the TeX file that I'm compiling?
Edits to this post
EDIT 1
Before I update A/A.tex with a document class and undo this, the output file says
Running 'pdflatex --max-print-line=10000 -synctex=1 -interaction=nonstopmode -file-line-error -recorder "c:/Users/.../B/B.tex"' The file being asked to compiled is indeed plain wrong. This fits perfectly with what I'm seeing. How can this be corrected in VSCode?
EDIT 2
I also see that the LaTeX Workshop extension has a configuration option for automatic root file detection. This automatic detection is not working in my favour here. How can I disable this? Neither of the two existing options are what I want.



latex mainnotlatex some/path/to/mainso that the relative paths agree.Running 'pdflatex --max-print-line=10000 -synctex=1 -interaction=nonstopmode -file-line-error -recorder "c:/Users/.../A/A.tex"'. This tells me that LaTeX Workshop never starts latex from the main document folder anyway. Doesn't mean you're not on to something.