Right now I'm using TeXStudio with pdflatex on MikTeX on Windows 10 (64-bit).

What I'm doing is that I have hierarchy of folders:

  • "root" / Project's directory (contains project-specific .sty package)
    • Sub-Project 1 (contains the master document for this sub-project)
      • Sub-Project 1 content (contains a bunch of .tex files with content)
    • Sub-Project 2 (contains the master document for this sub-project)
      • Sub-Project 2 content (contains a bunch of .tex files with content)
    • ...

Now as per the Wikibook I'm using subfiles to include from the sub-project's main document the content documents. The main document also includes the project-specific style package.

Now when I'm using TeXStudio, I have to open the master document and compile when viewing it to look at my compiled sub-document, the reason seems to lie in relative paths. That is if I compile from a content-document I get

File `../project1.sty' not found. \usepackage

as my error message.

As this is (slowly) getting annoying, how can I fix this error?

For your convenience, a content document template roughly looks like:

% content goes here

And the relevant parts of the master document looks like:

% other packages and some configuration
% other includes go here, includes are auto-generated using a macro

The upper document would live in /project1/subproject1/tex/part1.tex.
And the lower would live in /project1/subproject1/master.tex.
The style package would live in /project1/project1.sty.

  • In TeXStudio there is the option to declare the current document to be the master document. This is done under "Options>Root Document". – Skillmon Jul 4 '17 at 12:12
  • @Skillmon you are right, this is exactly what I needed. Would you mind posting this as an answer? – SEJPM Jul 4 '17 at 12:14

TeXStudio offers the option to declare a file as the master file. This is done in "Options > Root Document". This should also work in Texmaker.

  • 4
    You can also add a "magic command" as the file header. From sect 4.10 of TeXStudio Manual: '% !TeX root = filename' defines the root document (i.e. the file which will be passed to the LaTeX compiler when building). This setting overrides the automatic root detection in TeXstudio. In turn, it's overridden, if an explict root document is set at Options -> Root Document. – Ross Jul 4 '17 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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