In my main.tex I am requesting my preamble to be loaded through the command \usepackage{preamble}, which is in the same folder as my main.tex. My subfiles are located one folder below, e.g. MAIN/introduction/introduction.tex.

I would like to compile my subfiles as individual documents as well, but I get the error preamble.sty not found, which I presume is because I do not have a preamble.tex file located in my subfile folders, only in the main folder.

Is there a possible way around this? For example, would I be able to specify two paths for my preamble, e.g. \usepackage{preamble} when I am compiling my main document and \usepackage{../preamble} when I am compiling my subfile?

Thanks for the help.


My preamble is in .sty format, and I load it in my main.tex with \usepackage{preamble}. I am unable to write the same thing in my subfile document because AFAIK the layout of a subfile has to only have \documentclass[main.tex]{subfiles}. Otherwise, I would also write \usepackage{../preamble} in my subfile document.

My folder structure is as follows:


When I compile main.tex with \usepackage{preamble}, it works just fine. When I compile introduction.tex, I get the error that preamble.sty not found, even if I add \usepackage{../preamble}. I am using the subfiles package to create my subfiles.

  • 1
    Welcome to TeX.SE. The command \usepackage{preable} tells LaTeX to install a package (typically with extension .sty) named preamble... and so far as I know there is no such package by that name. If you want to include preamble.tex, just use \input{preamble.tex} instead-- if it is in the main folder with your main.tex, I think it should connect properly. – Partha D. Feb 11 at 4:39
  • To use the same preamble for the tex files in your subfolder, use \input{../preamble.tex} there. – Partha D. Feb 11 at 4:48
  • @ParthaD. Yes I've done that. My preamble is a .sty format and I load it with \usepackage. I have tried writing \usepackage{../preamble} in my subfile document to tell it to locate the preamble one folder above, but I am thrown an error. I suspect it's because subfiles is strict on the subfiles' layout (i.e. only \documentclass[main.tex]{subfiles}) is permitted. – Richard Gao Feb 11 at 7:15
  • @RichardGao Can you provide your folder structure? – MadyYuvi Feb 11 at 7:24
  • @MadyYuvi Absolutely. I've edited my original post, hopefully it's more clear. – Richard Gao Feb 11 at 16:39

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.