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

Cannot find the correct root file #776

Closed
wyunnn opened this issue Sep 5, 2018 · 16 comments
Closed

Cannot find the correct root file #776

wyunnn opened this issue Sep 5, 2018 · 16 comments
Labels
need more info More information needed to identify the issue

Comments

@wyunnn
Copy link

wyunnn commented Sep 5, 2018

It seems latex workshop cannot find the correct root file.
My files can be correctly built when I am under the main.tex window.

However, when I am editing other files and save it, it shows
"Found root file by the magic comment: [....\article.tex]", but actually the file article.tex does not exist. It continuously runs "parsing" and does not complete running for a long time.

@jlelong
Copy link
Collaborator

jlelong commented Sep 5, 2018

It looks like you have a wrong magic comment % !TeX root.
Can you give us a minimal example reproducing the problem?

@wyunnn
Copy link
Author

wyunnn commented Sep 5, 2018

I did not use any magic comment in all my tex files.

Why does it continuously run and show the output like this?
[22:56:55] Root file remains unchanged from: c:\Users\Paper\main.tex.
[22:57:22] Try root file in root directory: c:\Users\Paper\main.tex
[22:57:22] Parsing c:\Users\Paper\main.tex
[22:57:22] Parsing c:\Users\texfiles\abstract.tex
[22:57:22] Parsing c:\Users\texfiles\intro.tex
[22:57:22] Parsing c:\Users\texfiles\relatedwork.tex
[22:57:22] Parsing c:\Users\texfiles\methodology.tex
[22:57:22] Parsing c:\Users\texfiles\conclusion.tex

When I try to build from other files (except the root file), it does not work.

@jlelong
Copy link
Collaborator

jlelong commented Sep 6, 2018

I cannot reproduce the problem, can you provide a minimal example?

@jlelong jlelong added the need more info More information needed to identify the issue label Sep 7, 2018
@oerpli
Copy link
Contributor

oerpli commented Sep 14, 2018

@wyunnn , if you're still having problems, try the following:

  1. Open the project folder with VS Code (make sure, that your root file is in some subdirectory of this folder)
  2. Open the .tex file from which you want to compile the document
  3. Press F1 (or whatever hotkey you have assigned to the "Show All Commands"-command
  4. Enter "root magic" - this should find the command "latex-workshop.addtexroot" (full name: Insert %!TeX root magic command) and pick the command.
  5. A list of .tex files in the projects should open - start typing the name of your desired root file (main.tex) and press enter. This inserts a correctly formatted root-comment and removes incorrectly formatted/old root-comments (if if recognizes them)
  6. Save the file and compile.

@wyunnn
Copy link
Author

wyunnn commented Sep 14, 2018

Thank you!
It works when I insert the correct root magic command.
But when I remove the magic commands, it cannot find the root file (with \begin{document}) by itself...

@oerpli
Copy link
Contributor

oerpli commented Sep 14, 2018

Just don't remove it.

@jlelong
Copy link
Collaborator

jlelong commented Sep 14, 2018

As pointed out by @oerpli, it is very important that your main file is in some subdirectory of the folder opened in VSCode. Looking at your logs

[22:56:55] Root file remains unchanged from: c:\Users\Paper\main.tex.
[22:57:22] Try root file in root directory: c:\Users\Paper\main.tex
[22:57:22] Parsing c:\Users\Paper\main.tex
[22:57:22] Parsing c:\Users\texfiles\abstract.tex
[22:57:22] Parsing c:\Users\texfiles\intro.tex
[22:57:22] Parsing c:\Users\texfiles\relatedwork.tex
[22:57:22] Parsing c:\Users\texfiles\methodology.tex
[22:57:22] Parsing c:\Users\texfiles\conclusion.tex

it means you have to open c:\Users\ in VSCode.

@jlelong
Copy link
Collaborator

jlelong commented Sep 18, 2018

Is it solved?

@wyunnn
Copy link
Author

wyunnn commented Sep 19, 2018

When I use the magic command, it works.

I tried to open it in the upper layer folder
When I remove the magic command, It shows
[11:06:06] Could not resolve included file c:\Users\Paper\main.tex

@jlelong
Copy link
Collaborator

jlelong commented Sep 19, 2018

This is very strange. Can you post a zip of minimal example, so that I can track what is going on?

@jlelong jlelong closed this as completed Sep 27, 2018
@SimonZsx
Copy link

Hi all, I encountered the same Issue when I used LaTex Workshop in Win10 while including sub files with the LaTex package import.
I tried the root magic but it still failed.
I resolve this issue by changing the import{sections/}{xxx.tex} to include {sections/xxx.tex}.
BTW, the import package works fine under my MacOS environment, I think there might be some OS related issue with the import package.

@paddymccrudden
Copy link

I have a very similar problem. It would be great if the installation instructions were more comprehensive.

@jlelong
Copy link
Collaborator

jlelong commented Jun 5, 2019

@SimonZsx From the import package documentation

\import{〈full_path〉}{〈file〉}
\subimport{〈path_extension〉}{〈file〉}

It looks like that you should be using subimport instead of import.

@jlelong
Copy link
Collaborator

jlelong commented Jun 5, 2019

@paddymccrudden Have a look at the wiki and feel free to make a PR if you think some extra information should be added.

@SimonZsx
Copy link

SimonZsx commented Jun 5, 2019

Yes, that's a great solution. Thanks a lot!

@paddymccrudden
Copy link

Thanks guys - I got it working. Very nice package.

Repository owner locked as resolved and limited conversation to collaborators Dec 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need more info More information needed to identify the issue
Projects
None yet
Development

No branches or pull requests

5 participants